Menu

 

Sunday, July 18, 2010

Refrence Collections :- (A) :- Addins Collection

VBA Code :-

For Each ad In AddIns
If ad.Installed = True Then
MsgBox ad.Name & " is installed"
Else
MsgBox ad.Name & " is available but not installed"
End If
Next ad

C# Code

public void findaddin()
{



foreach (Word.AddIn ad in this.Application.AddIns)
{
string straddinname = ad.Name;
if (ad.Installed == true)
{
}
else
{
MessageBox.Show(straddinname);
}

}
}

VBA Code :-

AddIns.Add FileName:="C:\Templates\Other\Letter.dot", Install:=True

C# Code :-

public void AddAddins()
{
string FileName = @"C:\Templates\Other\Letter.dot";
object Installed = true;
this.Application.AddIns.Add(FileName, ref Installed);
}

VBA Code :-

Set rac = ActiveDocument.Shapes _
.AddShape(msoShapeRightArrowCallout, 10, 10, 250, 190)
With rac.Adjustments
.Item(1) = 0.5 'adjusts width of text box
.Item(2) = 0.15 'adjusts width of arrow head
.Item(3) = 0.8 'adjusts length of arrow head
.Item(4) = 0.4 'adjusts width of arrow neck
End With

C# Code :-

public void Addjustment()
{

int myvalue = (int)Microsoft.Office.Core.MsoAutoShapeType.msoShapeRightArrowCallout;
Word.Shape rac = this.Application.ActiveDocument.Shapes.AddShape(myvalue, 10.0f, 10.0f, 250.0f, 190.0f, ref missing);
rac.Adjustments[1] = 0.5f;
rac.Adjustments[2] = 0.15f;
rac.Adjustments[3] = 0.8f;
rac.Adjustments[4] = 0.4f;

}

VBA Code :-

For Each autoCap In AutoCaptions
If autoCap.AutoInsert = True Then
MsgBox autoCap.Name & " is configured for auto insert"
End If
Next autoCap

C# Code :-

public void AutocaptionCollection()
{

foreach(Word.AutoCaption autocap in ThisApplication.AddIns.Application.AutoCaptions )
{
if (autocap.AutoInsert == true)
{
MessageBox.Show(autocap.Name);
}
else
{
MessageBox.Show(autocap.Name);
}
}
}

VBA Code :-

AutoCaptions("Microsoft Word Table").CaptionLabel.Name

C# Code :-

public void ReadAutoCaptionIndex()
{
object NameIndex = "Microsoft Word Table";
string name = "";
name = ThisApplication.AddIns.Application.AutoCaptions.get_Item(ref NameIndex).Application.CaptionLabels.Application.Name;
MessageBox.Show(name);
}

VBA Code :-

AutoCaptions(1).Name

C# Code :-

public void ReadAutoCaptionnumericIndex()
{
object NameIndex = "1";
string name = "";
name = ThisApplication.AddIns.Application.AutoCaptions.get_Item(ref NameIndex).Application.CaptionLabels.Application.Name;
MessageBox.Show(name);
}

VBA Code :-

MsgBox AutoCorrect.Entries.Count

C# Code :-

public void countAutoCorrect()
{
int totalCount = this.Application.AutoCorrect.Entries.Count;
MessageBox.Show(totalCount.ToString());
}

VBA Code :-

AutoCorrect.Entries.Add Name:="thier", Value:="their"

C# Code :-

{
string name = "thier";
string value = "their";
this.Application.AutoCorrect.Entries.Add( name, value);
}

VBA Code :-

AutoCorrect.Entries.AddRichText Name:="PMO", Range:=Selection.Range

C# Code :-

public void AddRichText()
{
string name = "thier";
Word.Range wr = this.Application.Selection.Range;
this.Application.AutoCorrect.Entries.AddRichText(name, wr);

}

VBA Code :-

AutoCorrect.Entries("teh").Value = "the"

C# Code :-

public void autocorrctwordIndex()
{
object obValue = "teh";
this.Application.AutoCorrect.Entries.get_Item(ref obValue).Value = "the";
}

VBA Code :-

MsgBox "Name = " & AutoCorrect.Entries(1).Name & vbCr & _
"Value " & AutoCorrect.Entries(1).Value

C# Code :-

public void AutoCorrectEntriesIndex()
{
object Indexvalue = 1;
string strName = this.Application.AutoCorrect.Entries.get_Item(ref Indexvalue).Name;

MessageBox.Show(strName);

string strValue = this.Application.AutoCorrect.Entries.get_Item(ref Indexvalue).Value;
MessageBox.Show(strValue);
}

VBA Code :-

For Each i In NormalTemplate.AutoTextEntries
If LCase(i.Name) = "test" Then MsgBox "AutoText entry exists"
Next i

C# Code :-

public void AutotextEntries()
{

int countAutoTextEntries = ThisApplication.NormalTemplate.AutoTextEntries.Count;


int i = 1;
while (i <= countAutoTextEntries)
{
object objName = i;
string strname = ThisApplication.NormalTemplate.AutoTextEntries.get_Item(ref objName).Name;
if (strname == "test")
{
MessageBox.Show("Text AutoText Entry exists");
}
i++;
}
}

VBA Code :-

NormalTemplate.AutoTextEntries.Add Name:="Blue", _
Range:=Selection.Range

C# Code :-

public void AddAutotextEntries()
{
string name = "Avinash";
Word.Range wr = this.Application.Selection.Range;
ThisApplication.NormalTemplate.AutoTextEntries.Add(name, wr);
}

VBA code :-

NormalTemplate.AutoTextEntries("cName").Value = _
"The Johnson Company"

C# Code :-

public void AutoTextEntries()
{
object cName = "cName";
ThisApplication.NormalTemplate.AutoTextEntries.get_Item(ref cName).Value = "This Avinash Company";
}

VBA Code :-

Set myTemplate = ActiveDocument.AttachedTemplate
MsgBox "Name = " & myTemplate.AutoTextEntries(1).Name & vbCr _
& "Value " & myTemplate.AutoTextEntries(1).Value

C# Code :-

blic void AutotexrEntries()
{
Word.Template myTemplate = (Word.Template)this.Application.ActiveDocument.get_AttachedTemplate();
int mytempcount = myTemplate.AutoTextEntries.Count;

int i = 1;
while (i <= mytempcount)
{
object objName = i;
string strname = ThisApplication.NormalTemplate.AutoTextEntries.get_Item(ref objName).Name;
string strValue = ThisApplication.NormalTemplate.AutoTextEntries.get_Item(ref objName).Value;
i++;

}
}

No comments:

Post a Comment