VBA Code
Set Range1 = ActiveDocument.Words(1)
Set Range2 = ActiveDocument.Words(2)
C# Code
Word.Range Myrange = null;
Myrange = this.Application.ActiveDocument.Words[1];
Word.Range Myrange1 = null;
Myrange1 = this.Application.ActiveDocument.Words[2];
VBA Code
Set Range2 = Range1
C# Code
Word.Range Myrange = null;
Myrange = this.Application.ActiveDocument.Words[1];
Word.Range Myrange1 = null;
Myrange1 = Myrange;
VBA Code:-
Sub CopyWord()
Selection.Words(1).Copy
End Sub
C# Code :-
public void CopyWord()
{
Word.Selection myselection = this.Application.Selection;
myselection.Words[1].Copy();
}
VBA Code :-
Sub CopyParagraph()
ActiveDocument.Paragraphs(1).Range.Copy
End Sub
C# Code :-
public void CopyParagraph()
{
ThisApplication.Application.ActiveDocument.Paragraphs[1].Range.Copy();
}
VBA Code :-
Sub ChangeCase()
ActiveDocument.Words(1).Case = wdUpperCase
End Sub
C# Code :-
public void ChnageCase()
{
this.Application.ActiveDocument.Words[1].Case = Word.WdCharacterCase.wdUpperCase;
}
VBA Code :-
Sub ChangeSectionMargin()
Selection.Sections(1).PageSetup.BottomMargin = InchesToPoints(0.5)
End Sub
C# Code :-
public void ChangeSectionMargin()
{
this.Application.Selection.Sections[1].PageSetup.BottomMargin = this.Application.InchesToPoints(0.5f);
}
VBA Code :-
Sub DoubleSpaceDocument()
ActiveDocument.Content.ParagraphFormat.Space2
End Sub
C# Code :-
public void DoubleSpaceDocument()
{
this.Application.ActiveDocument.Content.ParagraphFormat.Space2();
}
VBA Code :-
Sub SetRangeForFirstTenCharacters()
Dim rngTenCharacters As Range
Set rngTenCharacters = ActiveDocument.Range(Start:=0, End:=10)
End Sub
C# Code :-
public void SetRangeForFirstTenCharacters()
{
Word.Range rngTenCharacters = null;
object start = 0;
object last = 10;
rngTenCharacters = this.Application.ActiveDocument.Range (ref start, ref last);
}
VBA Code :-
Sub SetRangeForFirstThreeWords()
Dim docActive As Document
Dim rngThreeWords As Range
Set docActive = ActiveDocument
Set rngThreeWords = docActive.Range(Start:=docActive.Words(1).Start, _
End:=docActive.Words(3).End)
End Sub
C# Code
public void SetRangeForFirstThreeWords()
{
Word.Document docActive = null;
Word.Range rngThreeeword = null;
docActive = this.Application.ActiveDocument;
object start = docActive.Words[1].Start;
object last = docActive.Words[1].End ;
rngThreeeword = docActive.Range(ref start, ref last);
}
VBA Code :-
ub SetParagraphRange()
Dim docActive As Document
Dim rngParagraphs As Range
Set docActive = ActiveDocument
Set rngParagraphs = docActive.Range(Start:=docActive.Paragraphs(2).Range.Start, _
End:=docActive.Paragraphs(3).Range.End)
End Sub
C# Code :-
public void SetParagraphRange()
{
Word.Document docActive = null;
Word.Range rngThreeeword = null;
docActive = this.Application.ActiveDocument;
object start = docActive.Words[1].Start;
object last = docActive.Paragraphs[1].End;
rngThreeeword = docActive.Range(ref start, ref last);
}
VBA Code :-
Sub BorderAroundFirstParagraph()
Selection.Paragraphs(1).Borders.Enable = True
End Sub
C# Code :-
public void BorderAroundFirstParagraph()
{
this.Application.Selection.Paragraphs[1].Borders.Enable = true;
}
VBA Code :-
Sub ShadeTableRow()
Selection.Tables(1).Rows(1).Shading.Texture = wdTexture10Percent
End Sub
C# Code :-
public void BorderAroundSelection()
{
this.Application.Selection.Tables[1].Rows[1].Shading.Texture = Microsoft.Office.Interop.Word.WdTextureIndex.wdTexture10Percent;
}
VBA Code :-
Sub ShadeTableRow()
If Selection.Tables.Count >= 1 Then
Selection.Tables(1).Rows(1).Shading.Texture = wdTexture25Percent
Else
MsgBox "Selection doesn't include a table"
End If
End Sub
C# Code :-
public void ShadeTableRow()
{
if (this.Application.Selection.Tables.Count >= 1)
{
this.Application.Selection.Tables[1].Rows.Shading.Texture = Microsoft.Office.Interop.Word.WdTextureIndex.wdTexture25Percent;
}
else
{
MessageBox.Show("Selection doesn't include a table");
}
}
VBA Code :-
Sub ShadeAllFirstRowsInTables()
Dim tblTable As Table
If Selection.Tables.Count >= 1 Then
For Each tblTable In Selection.Tables
tblTable.Rows(1).Shading.Texture = wdTexture30Percent
Next tblTable
End If
End Sub
C# Code :-
public void ShadeAllFirstRowsInTables()
{
Word.Table tblTable = null;
if (this.Application.Selection.Tables.Count >= 1)
{
foreach(Word.Table tblTableloop in this.Application.Selection.Tables)
{
tblTableloop.Rows[1].Shading.Texture = Microsoft.Office.Interop.Word.WdTextureIndex.wdTexture30Percent;
}
}
}
No comments:
Post a Comment