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;
}
Subscribe to:
Post Comments (Atom)
HI AVINASH,
ReplyDeletecould u help me in converting the following VBA to c#
VBA code:
with objWordDoc
.Formfields("lblfaxcurrentdate").Enabled=false
i just want disable particular field... thanks in advance
By
Dev.....