Menu

 

Saturday, July 31, 2010

Refernceing Collection :- (L) Lanuages,Lines,List Entries , Listlevel,List paragraphs , List ,List Collection

VBA Code :-

For Each la In Languages
Msgbox la.NameLocal
Next la

C# Code :-

public void Lang()
{
Word.Languages la = ThisApplication.Languages;

foreach (Word.Language wl in la)
{
string strLocalName = wl.Name;
MessageBox.Show(strLocalName);
}
}

VBA Code :-

Dim objLines As Lines

Set objLines = ActiveDocument.ActiveWindow.Panes(1) _
.Pages(1).Rectangles(1).Lines

C# Code :-

public void ObjLines()
{
Word.Lines objLines = null;
objLines = ThisApplication.ActiveDocument.ActiveWindow.Panes[1].Pages[1].Rectangles[1].Lines;
}

VBA Code :-

Dim objRectangle As Rectangle
Dim objLines As Lines

Set objRectangle = ActiveDocument.ActiveWindow _
.Panes(1).Pages(1).Rectangles(1)

If objRectangle.RectangleType = wdTextRectangle Then _
Set objLines = objRectangle.Lines

C# Code :-

public void RectangleLines()
{
Word.Rectangle objRectangle = null;
Word.Lines objLines = null;
objRectangle = ThisApplication.ActiveDocument.ActiveWindow.Panes[1].Pages[1].Rectangles[1];


if (objRectangle.RectangleType == Microsoft.Office.Interop.Word.WdRectangleType
.wdTextRectangle)
{
objLines = objRectangle.Lines;
}
}

VBA Code :-

For Each le In _
ActiveDocument.FormFields("Drop1").DropDown.ListEntries
MsgBox le.Name
Next le

C# Code :-

public void formFileds()
{

object item = 1;

int i=1;
foreach ( Word.ListEntries listEntries in ThisApplication.ActiveDocument.FormFields.get_Item(ref item).DropDown.ListEntries )
{
object getName = i;
string strName = listEntries.get_Item(ref getName).Name;
i++;

}
}

VBA Code :-

Set myField = _
ActiveDocument.FormFields.Add(Range:=Selection.Range, _
Type:=wdFieldFormDropDown)
With myField.DropDown.ListEntries
.Add Name:="Red"
.Add Name:="Blue"
.Add Name:="Green"
End With

C# Code :-

public void AddFiledSample()
{
Word.Range wordSelection = ThisApplication.Selection.Range;

ThisApplication.ActiveDocument.FormFields.Add(wordSelection, Microsoft.Office.Interop.Word.WdFieldType.wdFieldFormDropDown).DropDown.ListEntries.Add("Red", ref missing);

ThisApplication.ActiveDocument.FormFields.Add(wordSelection, Microsoft.Office.Interop.Word.WdFieldType.wdFieldFormDropDown).DropDown.ListEntries.Add("Blue", ref missing);

ThisApplication.ActiveDocument.FormFields.Add(wordSelection, Microsoft.Office.Interop.Word.WdFieldType.wdFieldFormDropDown).DropDown.ListEntries.Add("Green", ref missing);



}

VBA Code :-

Set mytemp = ActiveDocument.ListTemplates(1)
For Each lev In mytemp.ListLevels
lev.NumberStyle = wdListNumberStyleLowercaseLetter
Next lev

C# Code :-

public void ListofTempltes()
{
object i = 1;

Word.ListTemplates myTemp = ThisApplication.ActiveDocument.ListTemplates;
foreach (Word.ListTemplates lev in myTemp.get_Item(ref i).ListLevels)
{

}

}

VBA Code :-

ActiveDocument.ListTemplates(1).ListLevels(1).StartAt = 4

C# Code :-

public void ListLevelStarts()
{
object objlevel = 1;
Word.ListLevels wl = ThisApplication.ActiveDocument.ListTemplates.get_Item(ref objlevel).ListLevels;
foreach (Word.ListLevel wlevel in wl)
{
wlevel.StartAt = 4;
}
}

VBA Code :-

For Each para in ActiveDocument.ListParagraphs
para.Range.HighlightColorIndex = wdTurquoise
Next para

C# code :-

public void ListParagraph()
{
Word.ListParagraphs wlps = ThisApplication.ActiveDocument.ListParagraphs;

foreach (Word.Paragraph wllps in wlps)
{
wllps.Range.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdTurquoise;
}
}

VBA Code :-

For Each li In ActiveDocument.Lists
MsgBox li.CountNumberedItems
Next li

C# Code :-

public void ListsActive()
{
Word.Lists wordList = ThisApplication.ActiveDocument.Lists;

foreach (Word.List wrdlist in wordList)
{
string strCount =wrdlist.CountNumberedItems(ref missing, ref missing).ToString();
MessageBox.Show(strCount);
}
}

VBA Code :-

Set temp1 = ListGalleries(wdNumberGallery).ListTemplates(1)
ActiveDocument.Lists(2).ApplyListTemplate ListTemplate:=temp1

C# Code :-

public void ListGallies()
{
object indexno =1;

Word.ListGalleries temp1 = ThisApplication.ListGalleries;
Word.ListTemplates wrdlstTemp = temp1[Microsoft.Office.Interop.Word.WdListGalleryType.wdNumberGallery].ListTemplates;

Word.ListTemplate wordtemp = wrdlstTemp.get_Item(ref indexno);

this.Application.ActiveDocument.Lists[2].ApplyListTemplate(wordtemp, ref missing, ref missing);


}

VBA Code :-

For Each lt In ActiveDocument.ListTemplates
MsgBox "This is a multiple-level list template - " _
& lt.OutlineNumbered
Next LT

C# Code :-

public void listTemplate()
{
Word.ListTemplates wrdTemps = ThisApplication.ActiveDocument.ListTemplates;

foreach (Word.Template wrdTemp in wrdTemps)
{
string strname = wrdTemp.Name;
}
}

VBA Code :-

Set myLT = ActiveDocument.ListTemplates.Add
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=myLT

C# Code :-

public void ActiveListtemo()
{
object numberline =4;
object name ="test";
ThisApplication.ActiveDocument.ListTemplates.Add(ref numberline, ref name);
}

Refernce Collection :-(K) KeyBindings , KeyBound

VBA Code :-

CustomizationContext = NormalTemplate
For Each aKey In KeyBindings
Selection.InsertAfter aKey.Command & vbTab _
& aKey.KeyString & vbCr
Selection.Collapse Direction:=wdCollapseEnd
Next aKey

C# Code :-

public void CustomizationTest()
{
ThisApplication.CustomizationContext = ThisApplication.NormalTemplate;
Word.KeyBindings wordKeyBinding = ThisApplication.KeyBindings;

foreach(Word.KeyBinding wkeybinding in wordKeyBinding)
{
string strText = wkeybinding.Command + " " + wkeybinding.KeyString ;
ThisApplication.Selection.InsertAfter(strText);


object objDir = Word.WdCollapseDirection.wdCollapseEnd ;
ThisApplication.Selection.Collapse(ref objDir);
}
}

VBA Code :-

CustomizationContext = ActiveDocument
KeyBindings.Add KeyCategory:=wdKeyCategoryStyle, _
Command:="Heading 1", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyH)

C# Code :-

public void SpecialKey()
{
ThisApplication.CustomizationContext = ThisApplication.NormalTemplate;
string strCommand = "Heading 1";
Word._Global wrdGlobal = null ;

object wdKeyAlt = Microsoft.Office.Interop.Word.WdKey.wdKeyAlt;
object wdKeyH = Microsoft.Office.Interop.Word.WdKey.wdKeyH;

int keycode = wrdGlobal.BuildKeyCode(Microsoft.Office.Interop.Word.WdKey.wdKeyControl,ref wdKeyAlt,ref wdKeyH, ref missing);


ThisApplication.KeyBindings.Add(Microsoft.Office.Interop.Word.WdKeyCategory.wdKeyCategoryStyle, strCommand, keycode, ref missing, ref missing);
}

VBA Code :-

CustomizationContext = NormalTemplate
For Each myKey In KeysBoundTo(KeyCategory:=wdKeyCategoryCommand, _
Command:="FileNew")
myStr = myStr & myKey.KeyString & vbCr
Next myKey
MsgBox myStr

C# Code :-

public void KeyCatelog()
{
ThisApplication.CustomizationContext = ThisApplication.NormalTemplate;
Word.KeyBindings myKey = ThisApplication.KeyBindings;

foreach (Word.KeyBinding wrdKey in myKey)
{
string mystr = "";
mystr = mystr + wrdKey.KeyString;

}
}

Friday, July 30, 2010

Referncening Collection :- (I) Indexes, Inline Shapes

VBA Code :-

ActiveDocument.Indexes.Format = wdIndexClassic

C# Code :-

public void IndexesFormat()
{
ThisApplication.ActiveDocument.Indexes.Format = Microsoft.Office.Interop.Word.WdIndexFormat.wdIndexClassic;
}

VB A Code :-

Set myRange = ActiveDocument.Content
myRange.Collapse Direction:=wdCollapseEnd
ActiveDocument.Indexes.Add Range:=myRange, Type:=wdIndexRunin

C# Code :-

public void ActiveDocumentContent()
{
Word.Range myRange = ThisApplication.ActiveDocument.Content;
object direction = Word.WdCollapseDirection.wdCollapseEnd;
myRange.Collapse(ref direction);
object wdtype = Word.WdIndexType.wdIndexRunin;
ThisApplication.ActiveDocument.Indexes.Add(myRange, ref missing, ref missing, ref wdtype, ref missing, ref missing, ref missing, ref missing);
}

VBA Code :-

If ActiveDocument.Indexes.Count >= 1 Then
ActiveDocument.Indexes(1).Update
End If

C# Code :-

public void IndexsCount()
{
int indexActiveCount = ThisApplication.ActiveDocument.Indexes.Count;

if (indexActiveCount >= 1)
{
ThisApplication.ActiveDocument.Indexes[1].Update();
}
}

VBA Code :-

For Each iShape In ActiveDocument.InlineShapes
iShape.ConvertToShape
Next iShape

C# Code :-

public void ShapesCount()
{
Word.InlineShapes wordinlineShapes = ThisApplication.ActiveDocument.InlineShapes;

foreach (Word.InlineShape wls in wordinlineShapes)
{
wls.ConvertToShape();
}
}

Refernce Collection :- (F) HangualAndAlphabet, headersFooter, headerStyle, HTMLDIVSION, Hyperlinks

VBA Code :-

For Each aHan In AutoCorrect.HangulAndAlphabetExceptions
MsgBox aHan.Name
Next aHan

C# Code :-

public void HangulAndAlphabetExceptions()
{
Word.HangulAndAlphabetExceptions wordautoCorrect = ThisApplication.AutoCorrect.HangulAndAlphabetExceptions ;

foreach (Word.HangulAndAlphabetException wd in wordautoCorrect)
{
string strHangualExpection = wd.Name;
MessageBox.Show(strHangualExpection);
}
}

VBA Code :-

AutoCorrect.HangulAndAlphabetExceptions.Add Name:="hello

C# Code :-

public void AddHangualAlpaExecption()
{
string strName = "Hello";
ThisApplication.AutoCorrect.HangulAndAlphabetExceptions.Add(strName);
}

VBA Code :-

AutoCorrect.HangulAndAlphabetExceptions("goodbye").Delete

C# Code :-

public void DeleteHangulAlphaExecption()
{
int countHangul = ThisApplication.AutoCorrect.HangulAndAlphabetExceptions.Count;

for(int i = 1 ; i >= countHangul;i++)
{
object hangalCount = i;

string nameHangal = ThisApplication.AutoCorrect.HangulAndAlphabetExceptions.get_Item(ref hangalCount).Name;

if (nameHangal == "goodbye")
{
ThisApplication.AutoCorrect.HangulAndAlphabetExceptions.get_Item(ref hangalCount).Delete();

}

}
}

VBA Code :-

AutoCorrect.HangulAndAlphabetExceptions(1).Name

C# Code :-

public void DeleteHangulAlphaExecption()
{
int countHangul = ThisApplication.AutoCorrect.HangulAndAlphabetExceptions.Count;

for (int i = 1; i >= countHangul; i++)
{
object hangalCount = i;

string nameHangal = ThisApplication.AutoCorrect.HangulAndAlphabetExceptions.get_Item(ref hangalCount).Name;

MessageBox.Show(nameHangal);

}
}

VBA Code :-

With ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary)
If .Range.Text <> vbCr Then
MsgBox .Range.Text
Else
MsgBox "Footer is empty"
End If
End With

C# Code :-

public void HeadersFooter()
{
string strValue ="";
strValue = ThisApplication.ActiveDocument.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text;
if (strValue == "")
{
MessageBox.Show(strValue);
}
else
{
MessageBox.Show("Footer is Empty");
}

}

VBA Code :-

With ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text = "Header text"
.Footers(wdHeaderFooterPrimary).Range.Text = "Footer text"
End With

C# Code :-

public void HeaderFooterText()
{
ThisApplication.ActiveDocument.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Footer text";
ThisApplication.ActiveDocument.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Header text";


}

VBA Code :-

With ActiveDocument
.PageSetup.DifferentFirstPageHeaderFooter = True
.Sections(1).Footers(wdHeaderFooterFirstPage) _
.Range.InsertBefore _
"Written by Kate Edson"
End With

C# Code :-

public void DifferentFirstPageHeaderFooter()
{
if (ThisApplication.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter == 1)
{
string strValue = "Written by Avinash Tiwari";
ThisApplication.ActiveDocument.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage].Range.InsertBefore(strValue);
}
}

VBA Code :-

With ActiveDocument.Sections(1)
.PageSetup.DifferentFirstPageHeaderFooter = True
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
FirstPage:=True
End With

C# Code :-

public void DifferentFirstPageHeaderFootertest()
{
if (ThisApplication.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter == 1)
{
string strValue = "Written by Avinash Tiwari";
ThisApplication.ActiveDocument.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.InsertBefore(strValue);
}
}

VBA Code :-

MsgBox ActiveDocument.TablesOfContents(1).HeadingStyles.Count

C# Code :-

public void HeadingStylesCount()
{
int count = ThisApplication.ActiveDocument.TablesOfContents[1].HeadingStyles.Count;

MessageBox.Show(System.Convert.ToString(count));
}

VBA Code :-

Set myToc = ActiveDocument.TablesOfContents.Add _
(Range:=ActiveDocument.Range(0, 0), UseHeadingStyles:=True, _
LowerHeadingLevel:=3, UpperHeadingLevel:=1)
myToc.HeadingStyles.Add Style:="Title", Level:=2

C# Code :-

public void Toc()
{
object start = 0;
object end = 0;
object UseHeaderStyle = true;
object LowerHeadingLevel =3;
object UpperHeadingLevel =1;
Word.Range wordRanges = ThisApplication.ActiveDocument.Range(ref start,ref end);



Word.TableOfContents mttoc = ThisApplication.ActiveDocument.TablesOfContents.Add(wordRanges, ref UseHeaderStyle, ref UpperHeadingLevel, ref UpperHeadingLevel, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

object style = "Title";
short Level = 2;
mttoc.HeadingStyles.Add(ref style, Level);

}

VBA Code :-

Set myTOF = ActiveDocument.TablesOfFigures.Add _
(Range:=ActiveDocument.Range(0, 0), AddedStyles:="Title")
MsgBox myTOF.HeadingStyles(1).Style

C# Code :-

public void TOF()
{ object start = 0;
object end = 0;
Word.Range wordRanges = ThisApplication.ActiveDocument.Range(ref start,ref end);
object AddedStyles = "Title";

Word.TableOfFigures myTOF = ThisApplication.ActiveDocument.TablesOfFigures.Add(wordRanges, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref AddedStyles, ref missing, ref missing);

object prop = 1;
object strMyTOF = myTOF.HeadingStyles[1].get_Style();

}

VBA Code :-

With ActiveDocument.HTMLDivisions
.Add
.Item(Index:=1).Range.Text = "This is a new HTML division."
With .Item(1)
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleTriple
.LineWidth = wdLineWidth025pt
.Color = wdColorRed
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
.LineWidth = wdLineWidth050pt
.Color = wdColorBlue
End With
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleDouble
.LineWidth = wdLineWidth075pt
.Color = wdColorBrightGreen
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleDashDotDot
.LineWidth = wdLineWidth075pt
.Color = wdColorTurquoise
End With
End With
End With

C# Code :-

public void HTMLDivisions()
{
Word.Range wordRange = ThisApplication.Selection.Range;
object mywordRange = wordRange;
ThisApplication.ActiveDocument.HTMLDivisions.Add(ref mywordRange).Range.Text = "This is a new HTML division.";
Word.HTMLDivisions wordHtmlDivisions = ThisApplication.ActiveDocument.HTMLDivisions;
int htmlDivisonsCount = ThisApplication.ActiveDocument.HTMLDivisions.Count;
for(int i =1; i <= htmlDivisonsCount; i++)
{
object htmdiv = i;

///wdBorderBottom
wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleTriple;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderBottom].Color = Microsoft.Office.Interop.Word.WdColor.wdColorRed;


////wdBorderTop
wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleDot;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth050pt;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderTop].Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlue;

////wdBorderLeft

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleDouble;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth075pt;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderLeft].Color = Microsoft.Office.Interop.Word.WdColor.wdColorBrightGreen;

//// wdBorderRight


wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleDashDotDot;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].LineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth075pt;

wordHtmlDivisions[i].Borders[Microsoft.Office.Interop.Word.WdBorderType.wdBorderRight].Color = Microsoft.Office.Interop.Word.WdColor.wdColorTurquoise;



}
}

VBA Code :-

For Each hLink In Documents(1).Hyperlinks
If InStr(hLink.Address, "Microsoft") <> 0 Then
hLink.Follow
Exit For
End If
Next hLink

C# Code :-

public void HyperLinks()
{
Word.Hyperlinks myHyperLink = ThisApplication.ActiveDocument.Hyperlinks;
int hyperLink = myHyperLink.Count;


for(int i = 1 ; i >= hyperLink; i++)
{
object objAddress = i;

string strAddress = myHyperLink.get_Item(ref objAddress).Address;
if (hyperLink > 0)
{
if (strAddress.Contains("Microsoft"))
{
myHyperLink.get_Item(ref objAddress).Follow(ref missing, ref missing, ref missing,ref missing,ref missing );
}
}
}
}

VBA Code :-

ActiveDocument.Hyperlinks.Add Address:="http://www.msn.com/", _
Anchor:=Selection.Range

C# Code :-

public void ActiveDocumentHyperlinks()
{
object Anchor = ThisApplication.Selection.Range;
object Address = "http://www.msn.com/";
ThisApplication.ActiveDocument.Hyperlinks.Add( Anchor, ref Address, ref missing, ref missing, ref missing, ref missing);
}

VBA Code :-

If Selection.HyperLinks.Count >= 1 Then
Selection.HyperLinks(1).Follow
End If

C# Code :-

public void SelectionHyperlink()
{
int selHyperLinkCount = ThisApplication.Selection.Hyperlinks.Count;

if (selHyperLinkCount >= 1)
{
object hyperLinkFollow = 1;

ThisApplication.Selection.Hyperlinks.get_Item(ref hyperLinkFollow).Follow(ref missing, ref missing, ref missing, ref missing, ref missing);
}
}

Thursday, July 29, 2010

Refernce Collection :- (G) GroupShapes

VBA Code :-

With ActiveDocument.Shapes
.AddShape(msoShapeIsoscelesTriangle, _
10, 10, 100, 100).Name = "shpOne"
.AddShape(msoShapeIsoscelesTriangle, _
150, 10, 100, 100).Name = "shpTwo"
.AddShape(msoShapeIsoscelesTriangle, _
300, 10, 100, 100).Name = "shpThree"
With .Range(Array("shpOne", "shpTwo", "shpThree")).Group
.Fill.PresetTextured msoTextureBlueTissuePaper
.GroupItems(2).Fill.PresetTextured msoTextureGreenMarble
End With
End With

C# Code :-

public void GroupShapeCollection()
{
int typevalue = (int)Microsoft.Office.Core.MsoAutoShapeType.msoShapeIsoscelesTriangle;

ThisApplication.ActiveDocument.Shapes.AddShape(typevalue, 10.0f, 10.0f, 10.0f, 10.0f, ref missing).Name = "ShapeOne";

typevalue = (int)Microsoft.Office.Core.MsoAutoShapeType.msoShapeIsoscelesTriangle;

ThisApplication.ActiveDocument.Shapes.AddShape(typevalue, 150.0f, 10.0f, 100.0f, 100.0f, ref missing).Name = "shpTwo";

ThisApplication.ActiveDocument.Shapes.AddShape(typevalue, 300.0f, 10.0f, 100.0f, 100.0f, ref missing).Name = "shpThree";
///string[] names = new string[3] {"Matt", "Joanne", "Robert"};

string[] names = new string[3] {"ShapeOne","shpTwo","shpThree"};

object rangobj = names;
ThisApplication.ActiveDocument.Shapes.Range(ref rangobj).Group().Fill.PresetTextured(Microsoft.Office.Core.MsoPresetTexture.msoTextureBlueTissuePaper);
object objvalue = 2;

ThisApplication.ActiveDocument.Shapes.Range(ref rangobj).Group().GroupItems.get_Item(ref objvalue).Fill.PresetTextured(Microsoft.Office.Core.MsoPresetTexture.msoTextureGreenMarble);




}

Refernce Collection :- (F) Fileds , File Converter ,First letter Execption,FontNames,Foot Notes,Form fileds,Frames

VBA Code :-

Selection.Fields.Update

C# Code :-

public void FiledsUpdate()
{

ThisApplication.Selection.Fields.Update();
}

VBA Code :-

Selection.Collapse Direction:=wdCollapseStart
Set myField = ActiveDocument.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldDate)
MsgBox myField.Result

C# Code :-

public void SelectionCollpaseDir()
{
object dir = Word.WdCollapseDirection.wdCollapseStart;
ThisApplication.Selection.Collapse(ref dir);
Word.Range range = ThisApplication.Selection.Range;
object wdfileddate = Word.WdFieldType.wdFieldDate;
Word.Field wdFiled = ThisApplication.ActiveDocument.Fields.Add(range, ref wdfileddate, ref missing, ref missing);

string strName = (string)wdFiled.Result;
MessageBox.Show(strName);

}

VBA Code :-

If ActiveDocument.Fields.Count >= 1 Then
MsgBox "Code = " & ActiveDocument.Fields(1).Code & vbCr _
& "Result = " & ActiveDocument.Fields(1).Result & vbCr
End If

C# Code :-

public void ActiveDocumentFileds()
{
int filedCount = ThisApplication.ActiveDocument.Fields.Count;

if (filedCount >= 1)
{
string strCode = ThisApplication.ActiveDocument.Fields[1].Code.ToString();
string strResult = ThisApplication.ActiveDocument.Fields[1].Result.ToString();

MessageBox.Show(strCode);
MessageBox.Show(strResult);

}
}

VBA Code :-

For Each conv In FileConverters
If conv.FormatName = "WordPerfect 6.x" Then
MsgBox "WordPerfect 6.0 converter is installed"
End if
Next conv

C# Code :-

public void FileConverters()
{
Word.FileConverters fileConverts = ThisApplication.FileConverters;

foreach (Word.FileConverter conv in fileConverts)
{
if (conv.FormatName == "WordPerfect 6.x")
{
MessageBox.Show("WordPerfect 6.0 converter is installed");
}
}
}

VBA Code :-

MsgBox FileConverters(1).FormatName

C# Code :-

public void FileConverterFormatname()
{
object objIndex = 1;

string strFileCon = ThisApplication.FileConverters.get_Item(ref objIndex).FormatName;
}

VBA Code :-

For Each aExcept In AutoCorrect.FirstLetterExceptions
If aExcept.Name = "addr." Then aExcept.Delete
Next aExcept

C# Code :-

public void AutoCorrectFirstLetter()
{
Word.AutoCorrect wordAutoCorrect = ThisApplication.AutoCorrect;
foreach (Word.AutoCorrect cdAutoCorrect in wordAutoCorrect.FirstLetterExceptions )
{
string strName = cdAutoCorrect.Application.Name;
}

}

VBA Code :-

MsgBox PortraitFontNames.Count & " fonts available"

For Each aFont In FontNames
ActiveDocument.Range.InsertAfter aFont & vbCr
Next aFont

C# Code :-

public void PortraitFont()
{
int fontCount = 0;
fontCount = this.Application.FontNames.Count;
int i = 0;
foreach (Word.FontNames wdFontName in ThisApplication.FontNames)
{i++;

ThisApplication.ActiveDocument.Range(ref missing, ref missing).InsertAfter(wdFontName.Application.Name );
}
}

VBA Code :-

ActiveDocument.Footnotes.SwapWithEndnotes


Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.Footnotes.Add Range:=Selection.Range , _
Text:="The Willow Tree, (Lone Creek Press, 1996)."

C# Code :-

public void Footnotes()
{
ThisApplication.ActiveDocument.Footnotes.SwapWithEndnotes();

object directions = Word.WdCollapseDirection.wdCollapseEnd;

ThisApplication.Selection.Collapse(ref directions);
Word.Range range = ThisApplication.Selection.Range;
object strName = "Avinash Tiwari";
ThisApplication.ActiveDocument.Footnotes.Add(range, ref missing,ref strName);
}

VBA Code :-

If Selection.Footnotes.Count >= 1 Then
Selection.Footnotes(1).Reference.Font.ColorIndex = wdRed
End If

C# Code :-

public void SelFootnotes()
{
int countFootNotes = ThisApplication.Selection.Footnotes.Count;


ThisApplication.Selection.Footnotes[1].Reference.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdRed;

}

VBA Code :-

For Each aField In ActiveDocument.FormFields
If aField.Type = wdFieldFormTextInput Then count = count + 1
Next aField
MsgBox "There are " & count & " text boxes in this document"

C# Code :-

public void FormFileds()
{
int wordFileds = ThisApplication.ActiveDocument.FormFields.Count;
for (int wordFiledCount = 1; wordFiledCount >= wordFileds; wordFiledCount++)
{
object inIndex = wordFiledCount;
Word.FormFields wordfiles = ThisApplication.ActiveDocument.FormFields;

if (wordfiles.get_Item(ref inIndex).Type == Microsoft.Office.Interop.Word.WdFieldType.wdFieldFormTextInput)
{

}


}
}

VBA Code :-

Set ffield = ActiveDocument.FormFields.Add( _
Range:=ActiveDocument.Range(Start:=0,End:=0), _
Type:=wdFieldFormCheckBox)
ffield.CheckBox.Value = True

C# Code :-

public void formfiled()
{
Word.Range wordRange = this.Application.Selection.Range;
Word.FormField wf = ThisApplication.ActiveDocument.FormFields.Add(wordRange, Microsoft.Office.Interop.Word.WdFieldType.wdFieldFormCheckBox);
wf.CheckBox.Value = true;
}

VBA Code :-

ActiveDocument.FormFields("Text1").Result = "Don Funk"

C# Code :-

public void FormFileds()
{
object indexNumber =1;
ThisApplication.ActiveDocument.FormFields.get_Item(ref indexNumber).Result = "Avinash";
}

VBA Code :-

For Each aFrame In ActiveDocument.Frames
aFrame.Borders.Enable = False
Next aFrame

C# Code :-

public void FrameDoc()
{
Word.Frames wframe = ThisApplication.ActiveDocument.Frames;

foreach (Word.Frame wf in wframe)
{
wf.Borders.Enable = -1;
}
}

VBA Code :-

ActiveDocument.Frames.Add _
Range:=ActiveDocument.Paragraphs(1).Range

C# Code :-

public void FrameAdd()
{
Word.Range wr = ThisApplication.Selection.Range;

ThisApplication.ActiveDocument.Frames.Add(wr.Paragraphs[1].Range);
}

VBA Code :-

ActiveDocument.Sections(1).Range.Frames(1).TextWrap = True

C# Code :-

public void FrameTextWrap()
{
ThisApplication.ActiveDocument.Sections[1].Range.Frames[1].TextWrap = true;
}

Refernce-Collection :- (E) Editors, Email Signature Entries,Endnotes

VBA Code :-

Dim objEditor As Editor

Set objEditor = Selection.Editors.Add(wdEditorCurrent)

C# Code :-

public void Editor()
{
Word.Editors objEditor = this.Application.Selection.Editors;
object editors = Word.WdEditorType.wdEditorCurrent;
this.Application.Selection.Editors.Add(ref editors);

}

VBA Code :-

Sub NewEmailSignature()
With Application.EmailOptions.EmailSignature
.EmailSignatureEntries.Add "Jeff Smith", Selection.Range
.NewMessageSignature = "Jeff Smith"
End With
End Sub

C# Code :-

public void NewEmailSignature()
{
string name = "Avinash";
this.Application.EmailOptions.EmailSignature.EmailSignatureEntries.Add(name, Application.Selection.Range);

this.Application.EmailOptions.EmailSignature.NewMessageSignature = "Avinash Tiwari";
}

VBA Code :-

ActiveDocument.Endnotes.Location = wdEndOfSection

C# Code :-

public void EndNotesLoc()
{
ThisApplication.ActiveDocument.Endnotes.Location = Microsoft.Office.Interop.Word.WdEndnoteLocation.wdEndOfSection;
}

VBA Code :-

Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.Endnotes.Add Range:=Selection.Range , _
Text:="The Willow Tree, (Lone Creek Press, 1996)."

C# Code :-

public void CollpaseDir()
{
object Director = Word.WdCollapseDirection.wdCollapseEnd;

ThisApplication.Selection.Collapse(ref Director);


Word.Range range = ThisApplication.Selection.Range;
object text = "The Willow Tree, (Lone Creek Press, 1996).";

ThisApplication.ActiveDocument.Endnotes.Add(range, ref missing, ref text);
}

VB Code :-

If Selection.Endnotes.Count >= 1 Then
Selection.Endnotes(1).Reference.Font.ColorIndex = wdRed
End If

C# Code :-

public void selection()
{
int endNotesCount = ThisApplication.Selection.Endnotes.Count;

if (endNotesCount >= 1)
{
ThisApplication.Selection.Endnotes[1].Reference.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdRed;
}
}