Menu

 

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);


}

No comments:

Post a Comment