VBA Code :-
ActiveDocument.ActiveWindow.ActivePane _
.Zooms(wdNormalView).Percentage = 100
*
ActiveDocument.ActiveWindow.ActivePane _
.Zooms(wdPrintView).PageFit = wdPageFitFullPage
C# Code :-
public void ZoomCollection()
{
ThisApplication.ActiveDocument.ActiveWindow.ActivePane.Zooms.Item(Microsoft.Office.Interop.Word.WdViewType.wdNormalView).Percentage = 100;
ThisApplication.ActiveDocument.ActiveWindow.ActivePane.Zooms.Item(Microsoft.Office.Interop.Word.WdViewType.wdPrintPreview).PageFit = Microsoft.Office.Interop.Word.WdPageFit.wdPageFitFullPage;
}
Saturday, August 7, 2010
Refernce Collection (X) :- XmlChildNode Suggestion,XMlNameSpace,XMlNodes,XMLSchema,XSL Transform
VBA Code :-
Dim objSuggestion As XMLChildNodeSuggestion
Dim objNode As XMLNode
Set objNode = Selection.XMLNodes.Item(1)
For Each objSuggestion In objNode.ChildNodeSuggestions
objSuggestion.Insert
Selection.MoveRight
Next
C# Code :-
public void XmlChildCollection()
{
Word.XMLChildNodeSuggestion wordXmlChildNodeCollection = null;
Word.XMLNodes objNode = null;
int i =1;
objNode = ThisApplication.Selection.XMLNodes ;
foreach (Word.XMLChildNodeSuggestions wordXmlChild in objNode)
{
object objitem = i;
Word.Range wordrange = ThisApplication.Selection.Range;
object obj = wordrange;
wordXmlChild.get_Item(ref objitem).Insert(ref obj);
i++;
}
}
VBA Code :-
Sub ApplySampleSchema()
Dim objSchema As XMLNamespace
For Each objSchema In Application.XMLNamespaces
If objSchema.URI = "SimpleSample" Then
objSchema.AttachToDocument ActiveDocument
Exit For
End If
Next
End Sub
C# Code :-
public void ApplySampleSchema()
{
Word.XMLNamespaces objschema = ThisApplication.XMLNamespaces;
foreach (Word.XMLNamespace objSchema in objschema)
{
if (objSchema.URI == "SimpleSample")
{
object activeDocument = ThisApplication.ActiveDocument;
objSchema.AttachToDocument(ref activeDocument);
}
}
}
VBA Code :-
Dim objNode As XMLNode
For Each objNode In ActiveDocument.XMLNodes
objNode.Validate
If objNode.ValidationStatus <> wdXMLValidationStatusOK Then
MsgBox objNode.ValidationErrorText(True)
End If
Next
C# Code :-
public void XmlNodes()
{
Word.XMLNode objNode = null;
foreach (Word.XMLNode xmlnode in ThisApplication.ActiveDocument.XMLNodes)
{
if (xmlnode.ValidationStatus != Microsoft.Office.Interop.Word.WdXMLValidationStatus.wdXMLValidationStatusOK)
{
object objTrue = true;
xmlnode.SetValidationError(Microsoft.Office.Interop.Word.WdXMLValidationStatus.wdXMLValidationStatusOK, ref objTrue, true);
}
}
}
VBA Code :-
Dim objNode As XMLNode
Dim intResponse As Integer
Set objNode = Selection.XMLNodes.Add("example", "SimpleSample")
objNode.Validate
If objNode.ValidationStatus < 0 Then
intResponse = MsgBox("This element is invalid. " & _
"Are you sure you want to add it?", vbYesNo)
If intResponse = vbNo Then objNode.Delete
End If
C# Code :-
public void XmlNodes()
{
Word.XMLNodes xmlNodes = ThisApplication.ActiveDocument.XMLNodes;
Word.XMLNode xmlNode = ThisApplication.ActiveDocument.XMLNodes[1];
string stgrName = "example";
string strnamespace = "SimpleSample";
xmlNode = ThisApplication.Selection.XMLNodes.Add(stgrName, strnamespace, ref missing);
xmlNode.Validate();
if (xmlNode.ValidationStatus < 0)
{
}
}
VBA Code :-
Sub VerifySampleSchema()
Dim objNS As XMLNamespace
Dim objSchema As XMLSchemaReference
Dim blnSchemaAttached As Boolean
For Each objSchema In ActiveDocument.XMLSchemaReferences
If objSchema.NamespaceURI <> "SimpleSample" Then
blnSchemaAttached = False
Else
objSchema.Reload
blnSchemaAttached = True
Exit For
End If
Next
If blnSchemaAttached = False Then
Set objNS = Application.XMLNamespaces.Item("SimpleSample")
objNS.AttachToDocument (ActiveDocument)
End If
End Sub
C# Code :-
public void BerifySampleSchema()
{
bool myvalue = false;
foreach (Word.XMLSchemaReference xmlRef in ThisApplication.ActiveDocument.XMLSchemaReferences)
{
if (xmlRef.NamespaceURI != "SimpleSample")
{
myvalue = true;
}
else
{
myvalue = false;
}
}
}
Dim objSuggestion As XMLChildNodeSuggestion
Dim objNode As XMLNode
Set objNode = Selection.XMLNodes.Item(1)
For Each objSuggestion In objNode.ChildNodeSuggestions
objSuggestion.Insert
Selection.MoveRight
Next
C# Code :-
public void XmlChildCollection()
{
Word.XMLChildNodeSuggestion wordXmlChildNodeCollection = null;
Word.XMLNodes objNode = null;
int i =1;
objNode = ThisApplication.Selection.XMLNodes ;
foreach (Word.XMLChildNodeSuggestions wordXmlChild in objNode)
{
object objitem = i;
Word.Range wordrange = ThisApplication.Selection.Range;
object obj = wordrange;
wordXmlChild.get_Item(ref objitem).Insert(ref obj);
i++;
}
}
VBA Code :-
Sub ApplySampleSchema()
Dim objSchema As XMLNamespace
For Each objSchema In Application.XMLNamespaces
If objSchema.URI = "SimpleSample" Then
objSchema.AttachToDocument ActiveDocument
Exit For
End If
Next
End Sub
C# Code :-
public void ApplySampleSchema()
{
Word.XMLNamespaces objschema = ThisApplication.XMLNamespaces;
foreach (Word.XMLNamespace objSchema in objschema)
{
if (objSchema.URI == "SimpleSample")
{
object activeDocument = ThisApplication.ActiveDocument;
objSchema.AttachToDocument(ref activeDocument);
}
}
}
VBA Code :-
Dim objNode As XMLNode
For Each objNode In ActiveDocument.XMLNodes
objNode.Validate
If objNode.ValidationStatus <> wdXMLValidationStatusOK Then
MsgBox objNode.ValidationErrorText(True)
End If
Next
C# Code :-
public void XmlNodes()
{
Word.XMLNode objNode = null;
foreach (Word.XMLNode xmlnode in ThisApplication.ActiveDocument.XMLNodes)
{
if (xmlnode.ValidationStatus != Microsoft.Office.Interop.Word.WdXMLValidationStatus.wdXMLValidationStatusOK)
{
object objTrue = true;
xmlnode.SetValidationError(Microsoft.Office.Interop.Word.WdXMLValidationStatus.wdXMLValidationStatusOK, ref objTrue, true);
}
}
}
VBA Code :-
Dim objNode As XMLNode
Dim intResponse As Integer
Set objNode = Selection.XMLNodes.Add("example", "SimpleSample")
objNode.Validate
If objNode.ValidationStatus < 0 Then
intResponse = MsgBox("This element is invalid. " & _
"Are you sure you want to add it?", vbYesNo)
If intResponse = vbNo Then objNode.Delete
End If
C# Code :-
public void XmlNodes()
{
Word.XMLNodes xmlNodes = ThisApplication.ActiveDocument.XMLNodes;
Word.XMLNode xmlNode = ThisApplication.ActiveDocument.XMLNodes[1];
string stgrName = "example";
string strnamespace = "SimpleSample";
xmlNode = ThisApplication.Selection.XMLNodes.Add(stgrName, strnamespace, ref missing);
xmlNode.Validate();
if (xmlNode.ValidationStatus < 0)
{
}
}
VBA Code :-
Sub VerifySampleSchema()
Dim objNS As XMLNamespace
Dim objSchema As XMLSchemaReference
Dim blnSchemaAttached As Boolean
For Each objSchema In ActiveDocument.XMLSchemaReferences
If objSchema.NamespaceURI <> "SimpleSample" Then
blnSchemaAttached = False
Else
objSchema.Reload
blnSchemaAttached = True
Exit For
End If
Next
If blnSchemaAttached = False Then
Set objNS = Application.XMLNamespaces.Item("SimpleSample")
objNS.AttachToDocument (ActiveDocument)
End If
End Sub
C# Code :-
public void BerifySampleSchema()
{
bool myvalue = false;
foreach (Word.XMLSchemaReference xmlRef in ThisApplication.ActiveDocument.XMLSchemaReferences)
{
if (xmlRef.NamespaceURI != "SimpleSample")
{
myvalue = true;
}
else
{
myvalue = false;
}
}
}
Refernce Collection (W) :- Windows , Words
VBA Code :-
Windows.Arrange ArrangeStyle:=wdTiled
*
ActiveDocument.ActiveWindow.NewWindow
NewWindow
Windows.Add
*
MsgBox Windows(1).Caption
C# Code :-
public void WindowCollection()
{
object objwdTitled = Word.WdArrangeStyle.wdTiled;
ThisApplication.Windows.Arrange(ref objwdTitled);
ThisApplication.ActiveDocument.ActiveWindow.NewWindow();
object objActiveWindo = 1;
string strCaption = "";
strCaption = ThisApplication.Windows.get_Item(ref objActiveWindo).Caption;
}
VBA Code :-
MsgBox Selection.Words.Count & " words are selected"
With Selection.Words(1)
.Italic = True
.Font.Size = 24
End With
C# Code :-
public void SelectionWord()
{
int wordCount = ThisApplication.Selection.Words.Count;
ThisApplication.Selection.Words[1].Italic = 1;
ThisApplication.Selection.Words[1].Font.Size = 24;
}
Windows.Arrange ArrangeStyle:=wdTiled
*
ActiveDocument.ActiveWindow.NewWindow
NewWindow
Windows.Add
*
MsgBox Windows(1).Caption
C# Code :-
public void WindowCollection()
{
object objwdTitled = Word.WdArrangeStyle.wdTiled;
ThisApplication.Windows.Arrange(ref objwdTitled);
ThisApplication.ActiveDocument.ActiveWindow.NewWindow();
object objActiveWindo = 1;
string strCaption = "";
strCaption = ThisApplication.Windows.get_Item(ref objActiveWindo).Caption;
}
VBA Code :-
MsgBox Selection.Words.Count & " words are selected"
With Selection.Words(1)
.Italic = True
.Font.Size = 24
End With
C# Code :-
public void SelectionWord()
{
int wordCount = ThisApplication.Selection.Words.Count;
ThisApplication.Selection.Words[1].Italic = 1;
ThisApplication.Selection.Words[1].Font.Size = 24;
}
Refernce Collection (V) :- Variables , Version
VBA Code :-
For Each aVar In ActiveDocument.Variables
If aVar.Name = "Blue" Then num = aVar.Index
Next aVar
If num = 0 Then
ActiveDocument.Variables.Add Name:="Blue", Value:=6
Else
ActiveDocument.Variables(num).Value = 6
End If
C# Code :-
public void Variables()
{
Word.Variables wordvariables = ThisApplication.ActiveDocument.Variables;
int num = 0;
foreach (Word.Variable wordvar in wordvariables)
{
if (wordvar.Name == "Blue")
{
num = wordvar.Index;
}
string strName = "";
object obj = null;
if (num == 0)
{
strName = "Blue";
obj = 6;
ThisApplication.ActiveDocument.Variables.Add(strName, ref obj);
}
else
{
obj = num;
ThisApplication.ActiveDocument.Variables.get_Item(ref obj).Value = strName;
}
}
}
VBA Code :-
ScreenUpdating = False
With ActiveDocument.AttachedTemplate.OpenAsDocument
.Variables.Add Name:="UserName", Value:= Application.UserName
.Close SaveChanges:=wdSaveChanges
End With
C# Code :-
public void AttachedTemplateOpenAsDocument()
{
ThisApplication.ScreenUpdating = false;
string UserName = "Avinash";
object obj = this.Application.UserName;
Word.Template wordTemp = (Word.Template)ThisApplication.ActiveDocument.get_AttachedTemplate();
wordTemp.OpenAsDocument().Variables.Add(UserName, ref obj);
object objsavechanges = Word.WdSaveOptions.wdSaveChanges;
wordTemp.OpenAsDocument().Close(ref objsavechanges, ref missing, ref missing);
}
VBA Code :-
ActiveDocument.Versions.AutoVersion = wdAutoVersionOff
*
ActiveDocument.Versions.Save _
Comment:="incorporated Judy's revisions"
*
If ActiveDocument.Versions.Count >= 1 Then
With ActiveDocument.Versions(1)
MsgBox "Comment = " & .Comment & vbCr & "Author = " & _
.SavedBy & vbCr & "Date = " & .Date
End With
End If
C# Code :-
public void versioningSamples()
{
ThisApplication.ActiveDocument.Versions.AutoVersion = Microsoft.Office.Interop.Word.WdAutoVersions.wdAutoVersionOff;
object commenst = "Avinash revsion";
ThisApplication.ActiveDocument.Versions.Save(ref commenst);
if (ThisApplication.ActiveDocument.Versions.Count >= 1)
{
String comments = ThisApplication.ActiveDocument.Versions[1].Comment;
String SavedBy = ThisApplication.ActiveDocument.Versions[1].SavedBy;
}
}
For Each aVar In ActiveDocument.Variables
If aVar.Name = "Blue" Then num = aVar.Index
Next aVar
If num = 0 Then
ActiveDocument.Variables.Add Name:="Blue", Value:=6
Else
ActiveDocument.Variables(num).Value = 6
End If
C# Code :-
public void Variables()
{
Word.Variables wordvariables = ThisApplication.ActiveDocument.Variables;
int num = 0;
foreach (Word.Variable wordvar in wordvariables)
{
if (wordvar.Name == "Blue")
{
num = wordvar.Index;
}
string strName = "";
object obj = null;
if (num == 0)
{
strName = "Blue";
obj = 6;
ThisApplication.ActiveDocument.Variables.Add(strName, ref obj);
}
else
{
obj = num;
ThisApplication.ActiveDocument.Variables.get_Item(ref obj).Value = strName;
}
}
}
VBA Code :-
ScreenUpdating = False
With ActiveDocument.AttachedTemplate.OpenAsDocument
.Variables.Add Name:="UserName", Value:= Application.UserName
.Close SaveChanges:=wdSaveChanges
End With
C# Code :-
public void AttachedTemplateOpenAsDocument()
{
ThisApplication.ScreenUpdating = false;
string UserName = "Avinash";
object obj = this.Application.UserName;
Word.Template wordTemp = (Word.Template)ThisApplication.ActiveDocument.get_AttachedTemplate();
wordTemp.OpenAsDocument().Variables.Add(UserName, ref obj);
object objsavechanges = Word.WdSaveOptions.wdSaveChanges;
wordTemp.OpenAsDocument().Close(ref objsavechanges, ref missing, ref missing);
}
VBA Code :-
ActiveDocument.Versions.AutoVersion = wdAutoVersionOff
*
ActiveDocument.Versions.Save _
Comment:="incorporated Judy's revisions"
*
If ActiveDocument.Versions.Count >= 1 Then
With ActiveDocument.Versions(1)
MsgBox "Comment = " & .Comment & vbCr & "Author = " & _
.SavedBy & vbCr & "Date = " & .Date
End With
End If
C# Code :-
public void versioningSamples()
{
ThisApplication.ActiveDocument.Versions.AutoVersion = Microsoft.Office.Interop.Word.WdAutoVersions.wdAutoVersionOff;
object commenst = "Avinash revsion";
ThisApplication.ActiveDocument.Versions.Save(ref commenst);
if (ThisApplication.ActiveDocument.Versions.Count >= 1)
{
String comments = ThisApplication.ActiveDocument.Versions[1].Comment;
String SavedBy = ThisApplication.ActiveDocument.Versions[1].SavedBy;
}
}
Refence Collection :- (T) TAbleOFAuthorties , TableOfContent,TableOfFiq,Tables,TablesOfAuthorites,TableOFAutoCat,TableOfContents,TableOfFiq,TableStops
VBA Code :-
With ActiveDocument.TablesOfAuthorities(1)
.IncludeCategoryHeader = True
.Update
End With
C# Code :-
public void TOA()
{
ThisApplication.ActiveDocument.TablesOfAuthorities[1].IncludeCategoryHeader = true;
ThisApplication.ActiveDocument.TablesOfAuthorities[1].Update();
}
VBA Code :-
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfAuthorities.Add Range:=myRange, _
Passim:=True, Category:=0, EntrySeparator:=", "
C# Code :-
public void TOARange()
{
object start = 0;
object End = 0;
object Category = 0;
object Passim = true;
object EntrySeparator = ", ";
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.TablesOfAuthorities.Add(myRange, ref Category, ref missing, ref Passim, ref missing, ref missing, ref missing, ref EntrySeparator, ref missing, ref missing, ref missing);
}
VBA Code :-
ActiveDocument.TablesOfContents(1).UpdatePageNumbers
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfContents.Add Range:=myRange, _
UseFields:=False, UseHeadingStyles:=True, _
LowerHeadingLevel:=3, _
UpperHeadingLevel:=1
C# Code :-
public void TOAObject()
{
ThisApplication.ActiveDocument.TablesOfContents[1].UpdatePageNumbers();
object start = 0;
object End = 0;
object Category = 0;
object Passim = true;
object EntrySeparator = ", ";
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.TablesOfAuthorities.Add(myRange, ref Category, ref missing, ref Passim, ref missing, ref missing, ref missing, ref EntrySeparator, ref missing, ref missing, ref missing);
}
VBA Code :-
ActiveDocument.TablesOfFigures(1).UpdatePageNumbers
*
ActiveDocument.TablesOfFigures.Add Range:=Selection.Range, _
IncludeLabel:=True, IncludePageNumbers:=True
C# Code :-
public void TableFig()
{
ThisApplication.ActiveDocument.TablesOfFigures[1].UpdatePageNumbers();
object start = 0;
object End = 0;
object Include = true;
object IncludePagenumbers = true;
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.TablesOfFigures.Add(myRange, ref missing, ref Include, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref IncludePagenumbers, ref missing, ref missing, ref missing);
}
VBA Code :-
For Each aTable In ActiveDocument.Tables
aTable.Borders.OutsideLineStyle = wdLineStyleSingle
aTable.Borders.OutsideLineWidth = wdLineWidth025pt
aTable.Borders.InsideLineStyle = wdLineStyleNone
Next aTable
C# Code :-
public void TablewdLineStyle()
{
Word.Tables wordTables = ThisApplication.ActiveDocument.Tables;
foreach (Word.Table wordTable in wordTables)
{
wordTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
wordTable.Borders.OutsideLineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt;
wordTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
}
}
VBA Code :-
For Each aTable In ActiveDocument.Tables
aTable.Borders.OutsideLineStyle = wdLineStyleSingle
aTable.Borders.OutsideLineWidth = wdLineWidth025pt
aTable.Borders.InsideLineStyle = wdLineStyleNone
Next aTable
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Tables.Add Range:=myRange, NumRows:=3, NumColumns:=4
*
ActiveDocument.Tables(1).ConvertToText Separator:=wdSeparateByTabs
C# Code :-
public void TablewdLineStyle()
{
Word.Tables wordTables = ThisApplication.ActiveDocument.Tables;
foreach (Word.Table wordTable in wordTables)
{
wordTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
wordTable.Borders.OutsideLineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt;
wordTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
}
object start = 0;
object End = 0;
Word.Range wordRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.Tables.Add(wordRange, 3, 4, ref missing, ref missing);
object sep = Word.WdSeparatorType.wdSeparatorColon;
ThisApplication.ActiveDocument.Tables[1].ConvertToText(ref sep, ref missing);
}
VBA Code :-
ActiveDocument.TablesOfAuthorities.Format = wdTOAClassic
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfAuthorities.Add Range:=myRange, _
Passim:=True, Category:=0, EntrySeparator:= ", "
*
With ActiveDocument.TablesOfAuthorities(1)
.IncludeCategoryHeader = True
.Update
End With
C# Code :-
public void TablesOfAuth()
{
ThisApplication.ActiveDocument.TablesOfAuthorities.Format = Microsoft.Office.Interop.Word.WdToaFormat.wdTOADistinctive;
object start = 0;
object End = 0;
Word.Range wordRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
object passim = true;
object Category = 0;
object EntrySep = ", ";
ThisApplication.ActiveDocument.TablesOfAuthorities.Add(wordRange, ref Category, ref missing, ref passim, ref missing, ref EntrySep, ref missing, ref missing, ref missing, ref missing, ref missing);
ThisApplication.ActiveDocument.TablesOfAuthorities[1].IncludeCategoryHeader = true;
ThisApplication.ActiveDocument.TablesOfAuthorities[1].Update();
}
VBA Code :-
ActiveDocument.TablesOfContents.MarkEntry Range:=Selection.Range, _
Level:=2, Entry:="Introduction"
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfContents.Add Range:=myRange, _
UseFields:=False, UseHeadingStyles:=True, _
LowerHeadingLevel:=3, _
UpperHeadingLevel:=1
C# Code :-
public void MarkEntry()
{
Word.Range wordRange = ThisApplication.Selection.Range;
object Entery = "Introduction";
object Level = 2;
ThisApplication.ActiveDocument.TablesOfContents.MarkEntry(wordRange, ref Entery, ref missing, ref missing, ref Level);
object UserFiled = false;
object UseHeadingStyles = true;
object LowerHeadingLevel = 3;
object UpperHeadingLevel = 1;
ThisApplication.ActiveDocument.TablesOfContents.Add(wordRange, ref UseHeadingStyles, ref UpperHeadingLevel, ref LowerHeadingLevel, ref UserFiled, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
}
With ActiveDocument.TablesOfAuthorities(1)
.IncludeCategoryHeader = True
.Update
End With
C# Code :-
public void TOA()
{
ThisApplication.ActiveDocument.TablesOfAuthorities[1].IncludeCategoryHeader = true;
ThisApplication.ActiveDocument.TablesOfAuthorities[1].Update();
}
VBA Code :-
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfAuthorities.Add Range:=myRange, _
Passim:=True, Category:=0, EntrySeparator:=", "
C# Code :-
public void TOARange()
{
object start = 0;
object End = 0;
object Category = 0;
object Passim = true;
object EntrySeparator = ", ";
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.TablesOfAuthorities.Add(myRange, ref Category, ref missing, ref Passim, ref missing, ref missing, ref missing, ref EntrySeparator, ref missing, ref missing, ref missing);
}
VBA Code :-
ActiveDocument.TablesOfContents(1).UpdatePageNumbers
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfContents.Add Range:=myRange, _
UseFields:=False, UseHeadingStyles:=True, _
LowerHeadingLevel:=3, _
UpperHeadingLevel:=1
C# Code :-
public void TOAObject()
{
ThisApplication.ActiveDocument.TablesOfContents[1].UpdatePageNumbers();
object start = 0;
object End = 0;
object Category = 0;
object Passim = true;
object EntrySeparator = ", ";
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.TablesOfAuthorities.Add(myRange, ref Category, ref missing, ref Passim, ref missing, ref missing, ref missing, ref EntrySeparator, ref missing, ref missing, ref missing);
}
VBA Code :-
ActiveDocument.TablesOfFigures(1).UpdatePageNumbers
*
ActiveDocument.TablesOfFigures.Add Range:=Selection.Range, _
IncludeLabel:=True, IncludePageNumbers:=True
C# Code :-
public void TableFig()
{
ThisApplication.ActiveDocument.TablesOfFigures[1].UpdatePageNumbers();
object start = 0;
object End = 0;
object Include = true;
object IncludePagenumbers = true;
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.TablesOfFigures.Add(myRange, ref missing, ref Include, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref IncludePagenumbers, ref missing, ref missing, ref missing);
}
VBA Code :-
For Each aTable In ActiveDocument.Tables
aTable.Borders.OutsideLineStyle = wdLineStyleSingle
aTable.Borders.OutsideLineWidth = wdLineWidth025pt
aTable.Borders.InsideLineStyle = wdLineStyleNone
Next aTable
C# Code :-
public void TablewdLineStyle()
{
Word.Tables wordTables = ThisApplication.ActiveDocument.Tables;
foreach (Word.Table wordTable in wordTables)
{
wordTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
wordTable.Borders.OutsideLineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt;
wordTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
}
}
VBA Code :-
For Each aTable In ActiveDocument.Tables
aTable.Borders.OutsideLineStyle = wdLineStyleSingle
aTable.Borders.OutsideLineWidth = wdLineWidth025pt
aTable.Borders.InsideLineStyle = wdLineStyleNone
Next aTable
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Tables.Add Range:=myRange, NumRows:=3, NumColumns:=4
*
ActiveDocument.Tables(1).ConvertToText Separator:=wdSeparateByTabs
C# Code :-
public void TablewdLineStyle()
{
Word.Tables wordTables = ThisApplication.ActiveDocument.Tables;
foreach (Word.Table wordTable in wordTables)
{
wordTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
wordTable.Borders.OutsideLineWidth = Microsoft.Office.Interop.Word.WdLineWidth.wdLineWidth025pt;
wordTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleNone;
}
object start = 0;
object End = 0;
Word.Range wordRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
ThisApplication.ActiveDocument.Tables.Add(wordRange, 3, 4, ref missing, ref missing);
object sep = Word.WdSeparatorType.wdSeparatorColon;
ThisApplication.ActiveDocument.Tables[1].ConvertToText(ref sep, ref missing);
}
VBA Code :-
ActiveDocument.TablesOfAuthorities.Format = wdTOAClassic
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfAuthorities.Add Range:=myRange, _
Passim:=True, Category:=0, EntrySeparator:= ", "
*
With ActiveDocument.TablesOfAuthorities(1)
.IncludeCategoryHeader = True
.Update
End With
C# Code :-
public void TablesOfAuth()
{
ThisApplication.ActiveDocument.TablesOfAuthorities.Format = Microsoft.Office.Interop.Word.WdToaFormat.wdTOADistinctive;
object start = 0;
object End = 0;
Word.Range wordRange = ThisApplication.ActiveDocument.Range(ref start, ref End);
object passim = true;
object Category = 0;
object EntrySep = ", ";
ThisApplication.ActiveDocument.TablesOfAuthorities.Add(wordRange, ref Category, ref missing, ref passim, ref missing, ref EntrySep, ref missing, ref missing, ref missing, ref missing, ref missing);
ThisApplication.ActiveDocument.TablesOfAuthorities[1].IncludeCategoryHeader = true;
ThisApplication.ActiveDocument.TablesOfAuthorities[1].Update();
}
VBA Code :-
ActiveDocument.TablesOfContents.MarkEntry Range:=Selection.Range, _
Level:=2, Entry:="Introduction"
*
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.TablesOfContents.Add Range:=myRange, _
UseFields:=False, UseHeadingStyles:=True, _
LowerHeadingLevel:=3, _
UpperHeadingLevel:=1
C# Code :-
public void MarkEntry()
{
Word.Range wordRange = ThisApplication.Selection.Range;
object Entery = "Introduction";
object Level = 2;
ThisApplication.ActiveDocument.TablesOfContents.MarkEntry(wordRange, ref Entery, ref missing, ref missing, ref Level);
object UserFiled = false;
object UseHeadingStyles = true;
object LowerHeadingLevel = 3;
object UpperHeadingLevel = 1;
ThisApplication.ActiveDocument.TablesOfContents.Add(wordRange, ref UseHeadingStyles, ref UpperHeadingLevel, ref LowerHeadingLevel, ref UserFiled, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
}
Friday, August 6, 2010
Refernce Collection :- (S) Sections , Sentences , ShapesNodes , Shapes , SmartTagActions, SmartTagRecongnizers , SmartTag, Smart tags , SpellingSugges
VBA Code :-
With ActiveDocument.Sections.Last.Range
.Collapse Direction:=wdCollapseEnd
.InsertAfter "end of document"
End With
C# Code :-
public void SectionswdCollaseEnd()
{
object Directions = Word.WdCollapseDirection.wdCollapseEnd;
string strtext = "End of Document";
ThisApplication.ActiveDocument.Sections.Last.Range.Collapse(ref Directions);
ThisApplication.ActiveDocument.Sections.Last.Range.InsertAfter(strtext);
}
VBA Code :-
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Sections.Add Range:=myRange
myRange.InsertParagraphAfter
C# Code :-
public void insertPara()
{
object start = 0;
object end = 0;
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref end);
object objrange = myRange;
ThisApplication.ActiveDocument.Sections.Add(ref objrange, ref missing);
myRange.InsertParagraph();
}
VBA Code :-
MsgBox ActiveDocument.Sections.Count & " sections"
Selection.Paragraphs(1).Range.InsertBreak _
Type:=wdSectionBreakContinuous
MsgBox ActiveDocument.Sections.Count & " sections"
C# Code :-
public void wdsectionBreakContinous()
{
int secCount = ThisApplication.ActiveDocument.Sections.Count;
string strCount = System.Convert.ToString(secCount);
MessageBox.Show(strCount);
Word.WdBreakType wordBreak = Microsoft.Office.Interop.Word.WdBreakType.wdSectionBreakContinuous;
object objwordBreak = wordBreak;
ThisApplication.Selection.Paragraphs[1].Range.InsertBreak(ref objwordBreak);
}
VBA Code :-
With ActiveDocument.Sections(1).PageSetup
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
End With
C# Code :-
public void ActiveDocumentSection()
{
ThisApplication.ActiveDocument.Sections[1].PageSetup.LeftMargin = ThisApplication.InchesToPoints(0.5f);
ThisApplication.ActiveDocument.Sections[1].PageSetup.LeftMargin = ThisApplication.InchesToPoints(0.5f);
}
VBA Code :-
MsgBox Selection.Sentences.Count & " sentences are selected"
*
With ActiveDocument.Sentences(1)
.Bold = True
.Font.Size = 24
End With
C# Code :-
public void SentenceCount()
{
int SentenceCount = ThisApplication.Selection.Sentences.Count;
string strSentCount = System.Convert.ToString(SentenceCount);
MessageBox.Show(strSentCount);
ThisApplication.ActiveDocument.Sentences[1].Bold = 1;
ThisApplication.ActiveDocument.Sentences[1].Font.Size = 24.0f;
}
VBA Code :-
ActiveDocument.Shapes(3).Nodes.Delete 4
*
With ActiveDocument.Shapes(3).Nodes
.Insert 4, msoSegmentCurve, msoEditingSmooth, 210, 100
End With
*
With ActiveDocument.Shapes(3)
If .Nodes(1).EditingType = msoEditingCorner Then
.Nodes.SetEditingType 1, msoEditingSmooth
End If
End With
C# Code :-
public void ShapesNodecollections()
{
object objgetItem= 3;
ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Delete();
ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Nodes.Insert(4, Microsoft.Office.Core.MsoSegmentType.msoSegmentCurve, Microsoft.Office.Core.MsoEditingType.msoEditingSmooth, 210f, 100f, 0f, 0f, 0f, 0f);
if (ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Nodes.get_Item(ref objgetItem).EditingType == Microsoft.Office.Core.MsoEditingType.msoEditingCorner)
{
ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Nodes.SetEditingType(1, Microsoft.Office.Core.MsoEditingType.msoEditingSmooth);
}
}
VBA Code :-
ActiveDocument.Shapes.SelectAll
*
ActiveDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200
*
ActiveDocument.Shapes(1).Flip msoFlipHorizontal
C# Code :-
public void ShapesCollection()
{
object objId = 1;
ThisApplication.ActiveDocument.Shapes.SelectAll();
ThisApplication.ActiveDocument.Shapes.AddShape(1, 50f, 50f, 100f, 100f, ref missing);
ThisApplication.ActiveDocument.Shapes.get_Item(ref objId).Flip(Microsoft.Office.Core.MsoFlipCmd.msoFlipHorizontal);
}
VBA Code :-
Sub GetSmartTagsByType()
Dim objSmartTag As SmartTag
Dim objSmartTags As SmartTags
Dim strSmartTagName As String
strSmartTagName = "urn:schemas-microsoft-com" & _
":office:smarttags#address"
Set objSmartTags = ActiveDocument.SmartTags _
.SmartTagsByType(strSmartTagName)
For Each objSmartTag In objSmartTags
objSmartTag.SmartTagActions.ReloadActions
Next
End Sub
C# Code :-
public void GetSmartTagsType()
{
Word.SmartTags objSmartTags = null;
string strSmartTagName = "";
strSmartTagName = "urn:schemas-microsoft-com :office:smarttags#address";
objSmartTags = ThisApplication.ActiveDocument.SmartTags.SmartTagsByType(strSmartTagName);
foreach (Word.SmartTag objSmartTag in objSmartTags)
{
objSmartTag.SmartTagActions.ReloadActions();
}
}
VBA Code :-
Sub CheckforSmartTagRecognizers()
' Handle run-time error if no smart tag recognizers exist.
On Error Goto No_SmartTag_Recognizers_In_List
' Notify the user of the first smart tag recognizer item.
MsgBox "The first smart tag recognizer is: " & _
Application.SmartTagRecognizers.Item(1)
Exit Sub
No_SmartTag_Recognizers_In_List:
MsgBox "No smart tag recognizers exist in list."
End Sub
C# Code :-
public void CheckforSmartTagRecognizers()
{
object objItem =1;
string strCaptionName = "";
strCaptionName = ThisApplication.SmartTagRecognizers.get_Item(ref objItem).Caption;
}
VBA Code :-
Sub NewSmartTagProp()
ActiveDocument.SmartTags(1).Properties _
.Add Name:="President", Value:=True
End Sub
C# Code :-
public void NewSmartTagProp()
{
object objGetItem =1;
string strName ="Avinash";
string strValue = "Tiwari";
ThisApplication.ActiveDocument.SmartTags.get_Item(ref objGetItem).Properties.Add(strName, strValue);
}
VBA Code :-
For Each wd In ActiveDocument.Words
Set sugg = wd.GetSpellingSuggestions
If sugg.Count <> 0 Then
For Each ss In sugg
MsgBox ss.Name
Next ss
End If
Next wd
C# Code :-
public void SpellingSuggestion()
{
Word.SpellingSuggestions sugg = null;
foreach (Word.Application wd in ThisApplication.ActiveDocument.Words)
{
Word.Range wordRange = wd.Selection.Words[1];
string strValue = wordRange.Text ;
sugg = wd.GetSpellingSuggestions(strValue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
foreach(Word.SpellingSuggestion ss in sugg)
{
if(sugg.Count != 0)
{
string strName = ss.Name;
}
}
}
}
VBA Code :-
For Each sty In ActiveDocument.Styles
If sty.BuiltIn = False Then sty.Delete
Next sty
C# Code :-
public void ActiveDocumetStyles()
{
Word.Style wordStyle = null;
int i = 0;
foreach (Word.Styles wordstyle in ThisApplication.ActiveDocument.Styles)
{
object obji = i;
if (wordstyle.get_Item(ref obji ).BuiltIn == false)
{
wordstyle.get_Item(ref obji).Delete();
}
}
}
VBA Code :-
Set myStyle = ActiveDocument.Styles.Add(Name:="Introduction", _
Type:=wdStyleTypeCharacter)
With myStyle.Font
.Bold = True
.Italic = True
.Name = "Arial"
.Size = 12
End With
Selection.Range.Style = "Introduction"
C# Code :-
public void CreateWordStyle()
{
string Name = "Introduction";
object objStyle = Word.WdStyleType.wdStyleTypeCharacter;
Word.Style wordStyle = ThisApplication.ActiveDocument.Styles.Add(Name, ref objStyle);
wordStyle.Font.Bold = 1;
wordStyle.Font.Italic = 1;
wordStyle.Font.Name = "Arial";
wordStyle.Font.Size = 12;
object Introduction = "Introduction";
ThisApplication.Selection.Range.set_Style(ref Introduction);
}
VBA Code :-
Sub AddCSS()
With ActiveDocument.StyleSheets
.Add FileName:="Web.css", Title:="Web Styles"
.Add FileName:="New.css", Linktype:=wdStyleSheetLinkTypeImported, _
Title:="New Styles"
.Add FileName:="Defs.css", Title:="Definitions", _
Precedence:=wdStyleSheetPrecedenceHighest
End With
End Sub
C# Code :-
public void AddCSS()
{
string strName = "Web.css";
string strTitle = "Web Styles";
ThisApplication.ActiveDocument.StyleSheets.Add(strName, Microsoft.Office.Interop.Word.WdStyleSheetLinkType.wdStyleSheetLinkTypeImported, strTitle, Microsoft.Office.Interop.Word.WdStyleSheetPrecedence.wdStyleSheetPrecedenceHigher);
}
With ActiveDocument.Sections.Last.Range
.Collapse Direction:=wdCollapseEnd
.InsertAfter "end of document"
End With
C# Code :-
public void SectionswdCollaseEnd()
{
object Directions = Word.WdCollapseDirection.wdCollapseEnd;
string strtext = "End of Document";
ThisApplication.ActiveDocument.Sections.Last.Range.Collapse(ref Directions);
ThisApplication.ActiveDocument.Sections.Last.Range.InsertAfter(strtext);
}
VBA Code :-
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Sections.Add Range:=myRange
myRange.InsertParagraphAfter
C# Code :-
public void insertPara()
{
object start = 0;
object end = 0;
Word.Range myRange = ThisApplication.ActiveDocument.Range(ref start, ref end);
object objrange = myRange;
ThisApplication.ActiveDocument.Sections.Add(ref objrange, ref missing);
myRange.InsertParagraph();
}
VBA Code :-
MsgBox ActiveDocument.Sections.Count & " sections"
Selection.Paragraphs(1).Range.InsertBreak _
Type:=wdSectionBreakContinuous
MsgBox ActiveDocument.Sections.Count & " sections"
C# Code :-
public void wdsectionBreakContinous()
{
int secCount = ThisApplication.ActiveDocument.Sections.Count;
string strCount = System.Convert.ToString(secCount);
MessageBox.Show(strCount);
Word.WdBreakType wordBreak = Microsoft.Office.Interop.Word.WdBreakType.wdSectionBreakContinuous;
object objwordBreak = wordBreak;
ThisApplication.Selection.Paragraphs[1].Range.InsertBreak(ref objwordBreak);
}
VBA Code :-
With ActiveDocument.Sections(1).PageSetup
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
End With
C# Code :-
public void ActiveDocumentSection()
{
ThisApplication.ActiveDocument.Sections[1].PageSetup.LeftMargin = ThisApplication.InchesToPoints(0.5f);
ThisApplication.ActiveDocument.Sections[1].PageSetup.LeftMargin = ThisApplication.InchesToPoints(0.5f);
}
VBA Code :-
MsgBox Selection.Sentences.Count & " sentences are selected"
*
With ActiveDocument.Sentences(1)
.Bold = True
.Font.Size = 24
End With
C# Code :-
public void SentenceCount()
{
int SentenceCount = ThisApplication.Selection.Sentences.Count;
string strSentCount = System.Convert.ToString(SentenceCount);
MessageBox.Show(strSentCount);
ThisApplication.ActiveDocument.Sentences[1].Bold = 1;
ThisApplication.ActiveDocument.Sentences[1].Font.Size = 24.0f;
}
VBA Code :-
ActiveDocument.Shapes(3).Nodes.Delete 4
*
With ActiveDocument.Shapes(3).Nodes
.Insert 4, msoSegmentCurve, msoEditingSmooth, 210, 100
End With
*
With ActiveDocument.Shapes(3)
If .Nodes(1).EditingType = msoEditingCorner Then
.Nodes.SetEditingType 1, msoEditingSmooth
End If
End With
C# Code :-
public void ShapesNodecollections()
{
object objgetItem= 3;
ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Delete();
ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Nodes.Insert(4, Microsoft.Office.Core.MsoSegmentType.msoSegmentCurve, Microsoft.Office.Core.MsoEditingType.msoEditingSmooth, 210f, 100f, 0f, 0f, 0f, 0f);
if (ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Nodes.get_Item(ref objgetItem).EditingType == Microsoft.Office.Core.MsoEditingType.msoEditingCorner)
{
ThisApplication.ActiveDocument.Shapes.get_Item(ref objgetItem).Nodes.SetEditingType(1, Microsoft.Office.Core.MsoEditingType.msoEditingSmooth);
}
}
VBA Code :-
ActiveDocument.Shapes.SelectAll
*
ActiveDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200
*
ActiveDocument.Shapes(1).Flip msoFlipHorizontal
C# Code :-
public void ShapesCollection()
{
object objId = 1;
ThisApplication.ActiveDocument.Shapes.SelectAll();
ThisApplication.ActiveDocument.Shapes.AddShape(1, 50f, 50f, 100f, 100f, ref missing);
ThisApplication.ActiveDocument.Shapes.get_Item(ref objId).Flip(Microsoft.Office.Core.MsoFlipCmd.msoFlipHorizontal);
}
VBA Code :-
Sub GetSmartTagsByType()
Dim objSmartTag As SmartTag
Dim objSmartTags As SmartTags
Dim strSmartTagName As String
strSmartTagName = "urn:schemas-microsoft-com" & _
":office:smarttags#address"
Set objSmartTags = ActiveDocument.SmartTags _
.SmartTagsByType(strSmartTagName)
For Each objSmartTag In objSmartTags
objSmartTag.SmartTagActions.ReloadActions
Next
End Sub
C# Code :-
public void GetSmartTagsType()
{
Word.SmartTags objSmartTags = null;
string strSmartTagName = "";
strSmartTagName = "urn:schemas-microsoft-com :office:smarttags#address";
objSmartTags = ThisApplication.ActiveDocument.SmartTags.SmartTagsByType(strSmartTagName);
foreach (Word.SmartTag objSmartTag in objSmartTags)
{
objSmartTag.SmartTagActions.ReloadActions();
}
}
VBA Code :-
Sub CheckforSmartTagRecognizers()
' Handle run-time error if no smart tag recognizers exist.
On Error Goto No_SmartTag_Recognizers_In_List
' Notify the user of the first smart tag recognizer item.
MsgBox "The first smart tag recognizer is: " & _
Application.SmartTagRecognizers.Item(1)
Exit Sub
No_SmartTag_Recognizers_In_List:
MsgBox "No smart tag recognizers exist in list."
End Sub
C# Code :-
public void CheckforSmartTagRecognizers()
{
object objItem =1;
string strCaptionName = "";
strCaptionName = ThisApplication.SmartTagRecognizers.get_Item(ref objItem).Caption;
}
VBA Code :-
Sub NewSmartTagProp()
ActiveDocument.SmartTags(1).Properties _
.Add Name:="President", Value:=True
End Sub
C# Code :-
public void NewSmartTagProp()
{
object objGetItem =1;
string strName ="Avinash";
string strValue = "Tiwari";
ThisApplication.ActiveDocument.SmartTags.get_Item(ref objGetItem).Properties.Add(strName, strValue);
}
VBA Code :-
For Each wd In ActiveDocument.Words
Set sugg = wd.GetSpellingSuggestions
If sugg.Count <> 0 Then
For Each ss In sugg
MsgBox ss.Name
Next ss
End If
Next wd
C# Code :-
public void SpellingSuggestion()
{
Word.SpellingSuggestions sugg = null;
foreach (Word.Application wd in ThisApplication.ActiveDocument.Words)
{
Word.Range wordRange = wd.Selection.Words[1];
string strValue = wordRange.Text ;
sugg = wd.GetSpellingSuggestions(strValue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
foreach(Word.SpellingSuggestion ss in sugg)
{
if(sugg.Count != 0)
{
string strName = ss.Name;
}
}
}
}
VBA Code :-
For Each sty In ActiveDocument.Styles
If sty.BuiltIn = False Then sty.Delete
Next sty
C# Code :-
public void ActiveDocumetStyles()
{
Word.Style wordStyle = null;
int i = 0;
foreach (Word.Styles wordstyle in ThisApplication.ActiveDocument.Styles)
{
object obji = i;
if (wordstyle.get_Item(ref obji ).BuiltIn == false)
{
wordstyle.get_Item(ref obji).Delete();
}
}
}
VBA Code :-
Set myStyle = ActiveDocument.Styles.Add(Name:="Introduction", _
Type:=wdStyleTypeCharacter)
With myStyle.Font
.Bold = True
.Italic = True
.Name = "Arial"
.Size = 12
End With
Selection.Range.Style = "Introduction"
C# Code :-
public void CreateWordStyle()
{
string Name = "Introduction";
object objStyle = Word.WdStyleType.wdStyleTypeCharacter;
Word.Style wordStyle = ThisApplication.ActiveDocument.Styles.Add(Name, ref objStyle);
wordStyle.Font.Bold = 1;
wordStyle.Font.Italic = 1;
wordStyle.Font.Name = "Arial";
wordStyle.Font.Size = 12;
object Introduction = "Introduction";
ThisApplication.Selection.Range.set_Style(ref Introduction);
}
VBA Code :-
Sub AddCSS()
With ActiveDocument.StyleSheets
.Add FileName:="Web.css", Title:="Web Styles"
.Add FileName:="New.css", Linktype:=wdStyleSheetLinkTypeImported, _
Title:="New Styles"
.Add FileName:="Defs.css", Title:="Definitions", _
Precedence:=wdStyleSheetPrecedenceHighest
End With
End Sub
C# Code :-
public void AddCSS()
{
string strName = "Web.css";
string strTitle = "Web Styles";
ThisApplication.ActiveDocument.StyleSheets.Add(strName, Microsoft.Office.Interop.Word.WdStyleSheetLinkType.wdStyleSheetLinkTypeImported, strTitle, Microsoft.Office.Interop.Word.WdStyleSheetPrecedence.wdStyleSheetPrecedenceHigher);
}
Refernce Collection :- (R) Readability Statics, RecentFiles,Rectangle,Reviews,Revisons,Rows
VBA Code :-
For each rs in Selection.Range.ReadabilityStatistics
Msgbox rs.Name & " - " & rs.Value
Next rs
Set myRange = ActiveDocument.Content
wordval = myRange.ReadabilityStatistics(1).Value
Msgbox wordval
C# Code :-
public void ReadabilityStatics()
{
Word.ReadabilityStatistics wordReadStatics = ThisApplication.Selection.Range.ReadabilityStatistics;
foreach (Word.ReadabilityStatistic wordRead in wordReadStatics)
{
string strName = "";
strName = wordRead.Name;
float strValue ;
strValue = wordRead.Value;
}
VBA Code :-
RecentFiles.Maximum = 5
*
If ActiveDocument.Saved = True Then
RecentFiles.Add Document:=ActiveDocument.FullName, _
ReadOnly:=True
End If
*
If RecentFiles.Count >= 1 Then RecentFiles(1).Open
C# Code :-
public void RecentFiles()
{
ThisApplication.RecentFiles.Maximum = 5;
if (ThisApplication.ActiveDocument.Saved == true)
{
object document = ThisApplication.ActiveDocument.FullName;
object ReadOnly = true;
ThisApplication.RecentFiles.Add(ref document, ref ReadOnly);
}
if (ThisApplication.RecentFiles.Count >= 1)
{
ThisApplication.RecentFiles[1].Open();
}
}
VBA Code :-
Dim objRectangles As Rectangles
Set objRectangles = ActiveDocument.ActiveWindow _
.Panes(1).Pages(1).Rectangles
C# Code :-
public void Rectanges()
{
Word.Rectangles wordRect = ThisApplication.ActiveDocument.ActiveWindow.Panes[1].Pages[1].Rectangles;
}
VBA Code :-
Sub HideAuthorRevisions(blnRev As Boolean)
ActiveWindow.View.Reviewers(Index:=1) _
.Visible = False
End Sub
C# Code :-
public void hideAutorRevesion()
{
object objectvalue = 1;
ThisApplication.ActiveWindow.View.Reviewers.get_Item(ref objectvalue).Visible = false;
}
VBA Code :-
MsgBox ActiveDocument.Revisions.Count
*
For Each myRev In Selection.Range.Revisions
myRev.Accept
Next myRev
*
Set myRange = Selection.Paragraphs(1).Range
myRange.Revisions.AcceptAll
*
ActiveDocument.TrackRevisions = True
Selection.InsertBefore "The "
*
MsgBox ActiveDocument.Sections(1).Range.Revisions(1).Author
C# Code
public void Revisions()
{
int revCount = ThisApplication.ActiveDocument.Revisions.Count;
Word.Revisions wordRevesions = ThisApplication.Selection.Range.Revisions;
foreach (Word.Revision wordRev in wordRevesions)
{
wordRev.Accept();
}
Word.Range wordRange = ThisApplication.Selection.Paragraphs[1].Range;
wordRange.Revisions.AcceptAll();
ThisApplication.ActiveDocument.TrackRevisions = true;
string strInsertBefore = "The ";
ThisApplication.Selection.InsertBefore(strInsertBefore);
string strAutName = "";
strAutName = ThisApplication.ActiveDocument.Sections[1].Range.Revisions[1].Author;
}
VBA Code :-
ActiveDocument.Tables(1).Rows.Alignment = wdAlignRowCenter
*
If Selection.Information(wdWithInTable) = True Then
Selection.Rows.Add BeforeRow:=Selection.Rows(1)
End If
C# Code :-
public void RowAligment()
{
ThisApplication.ActiveDocument.Tables[1].Rows.Alignment = Microsoft.Office.Interop.Word.WdRowAlignment.wdAlignRowCenter;
bool isTable =(bool)ThisApplication.Selection.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdWithInTable);
if (isTable)
{
object before = 1;
ThisApplication.Selection.Rows.Add(ref before);
}
}
For each rs in Selection.Range.ReadabilityStatistics
Msgbox rs.Name & " - " & rs.Value
Next rs
Set myRange = ActiveDocument.Content
wordval = myRange.ReadabilityStatistics(1).Value
Msgbox wordval
C# Code :-
public void ReadabilityStatics()
{
Word.ReadabilityStatistics wordReadStatics = ThisApplication.Selection.Range.ReadabilityStatistics;
foreach (Word.ReadabilityStatistic wordRead in wordReadStatics)
{
string strName = "";
strName = wordRead.Name;
float strValue ;
strValue = wordRead.Value;
}
VBA Code :-
RecentFiles.Maximum = 5
*
If ActiveDocument.Saved = True Then
RecentFiles.Add Document:=ActiveDocument.FullName, _
ReadOnly:=True
End If
*
If RecentFiles.Count >= 1 Then RecentFiles(1).Open
C# Code :-
public void RecentFiles()
{
ThisApplication.RecentFiles.Maximum = 5;
if (ThisApplication.ActiveDocument.Saved == true)
{
object document = ThisApplication.ActiveDocument.FullName;
object ReadOnly = true;
ThisApplication.RecentFiles.Add(ref document, ref ReadOnly);
}
if (ThisApplication.RecentFiles.Count >= 1)
{
ThisApplication.RecentFiles[1].Open();
}
}
VBA Code :-
Dim objRectangles As Rectangles
Set objRectangles = ActiveDocument.ActiveWindow _
.Panes(1).Pages(1).Rectangles
C# Code :-
public void Rectanges()
{
Word.Rectangles wordRect = ThisApplication.ActiveDocument.ActiveWindow.Panes[1].Pages[1].Rectangles;
}
VBA Code :-
Sub HideAuthorRevisions(blnRev As Boolean)
ActiveWindow.View.Reviewers(Index:=1) _
.Visible = False
End Sub
C# Code :-
public void hideAutorRevesion()
{
object objectvalue = 1;
ThisApplication.ActiveWindow.View.Reviewers.get_Item(ref objectvalue).Visible = false;
}
VBA Code :-
MsgBox ActiveDocument.Revisions.Count
*
For Each myRev In Selection.Range.Revisions
myRev.Accept
Next myRev
*
Set myRange = Selection.Paragraphs(1).Range
myRange.Revisions.AcceptAll
*
ActiveDocument.TrackRevisions = True
Selection.InsertBefore "The "
*
MsgBox ActiveDocument.Sections(1).Range.Revisions(1).Author
C# Code
public void Revisions()
{
int revCount = ThisApplication.ActiveDocument.Revisions.Count;
Word.Revisions wordRevesions = ThisApplication.Selection.Range.Revisions;
foreach (Word.Revision wordRev in wordRevesions)
{
wordRev.Accept();
}
Word.Range wordRange = ThisApplication.Selection.Paragraphs[1].Range;
wordRange.Revisions.AcceptAll();
ThisApplication.ActiveDocument.TrackRevisions = true;
string strInsertBefore = "The ";
ThisApplication.Selection.InsertBefore(strInsertBefore);
string strAutName = "";
strAutName = ThisApplication.ActiveDocument.Sections[1].Range.Revisions[1].Author;
}
VBA Code :-
ActiveDocument.Tables(1).Rows.Alignment = wdAlignRowCenter
*
If Selection.Information(wdWithInTable) = True Then
Selection.Rows.Add BeforeRow:=Selection.Rows(1)
End If
C# Code :-
public void RowAligment()
{
ThisApplication.ActiveDocument.Tables[1].Rows.Alignment = Microsoft.Office.Interop.Word.WdRowAlignment.wdAlignRowCenter;
bool isTable =(bool)ThisApplication.Selection.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdWithInTable);
if (isTable)
{
object before = 1;
ThisApplication.Selection.Rows.Add(ref before);
}
}
Subscribe to:
Posts (Atom)