VBA Coded :-
For Each afield In ActiveDocument.MailMerge.DataSource.DataFields
MsgBox afield.Name
Next afield
C# Code :-
public void MailMergeDataFields()
{
Word.MailMergeDataFields wordMailFileds = ThisApplication.ActiveDocument.MailMerge.DataSource.DataFields;
foreach (Word.MailMergeDataField mailMergeDataFiled in wordMailFileds)
{
string strName = mailMergeDataFiled.Name;
}
}
VBA Code :-
If ActiveDocument.MailMerge.DataSource.Type = _
wdMergeInfoFromWord Then
ActiveDocument.MailMerge.EditDataSource
With ActiveDocument.Tables(1)
.Columns.Add
.Cell(Row:=1, Column:=.Columns.Count).Range.Text = "Author"
End With
End If
C# Code :-
public void MailMergeInfoWord()
{
if (ThisApplication.ActiveDocument.MailMerge.DataSource.Type == Microsoft.Office.Interop.Word.WdMailMergeDataSource.wdMergeInfoFromWord)
{
ThisApplication.ActiveDocument.MailMerge.EditDataSource();
ThisApplication.ActiveDocument.Tables[1].Columns.Add(ref missing).Cells.Add(ref missing).Range.Text = "Avinash";
}
}
VBA Code :-
MsgBox ActiveDocument.MailMerge.DataSource.DataFields(1).Name
C# Code :-
public void MailMergemessage()
{
object findName = 1;
string strName = ThisApplication.ActiveDocument.MailMerge.DataSource.DataFields.get_Item(ref findName).Name;
}
VBA Code :-
For Each afield In ActiveDocument.MailMerge.DataSource.FieldNames
MsgBox afield.Name
Next afield
C# Code :-
public void MailMergeDataFieldNames()
{
Word.MailMergeFieldNames wordMailFileds = ThisApplication.ActiveDocument.MailMerge.DataSource.FieldNames;
foreach (Word.MailMergeFieldName mailMergeDataFiled in wordMailFileds)
{
string strName = mailMergeDataFiled.Name;
}
}
VBA Code :-
Set myMMFields = ActiveDocument.MailMerge.Fields
myMMFields(myMMFields.Count).Select
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdMove
ActiveDocument.MailMerge.Fields.AddAsk Range:=Selection.Range, _
Name:="Name", Prompt:="Type your name", AskOnce:=True
C# Code :-
public void MailMergeFileds()
{
Word.MailMergeFields wordMMF = ThisApplication.ActiveDocument.MailMerge.Fields;
wordMMF[wordMMF.Count].Select();
object Unit = Word.WdUnits.wdWord;
object Count = 1;
object extend = Word.WdMovementType.wdMove;
Word.Range wrange = ThisApplication.Selection.Range;
string AddAskName = "Aviansh";
object prompt = "Type Your name";
object askonce = true;
ThisApplication.Selection.Move(ref Unit, ref Count);
ThisApplication.ActiveDocument.MailMerge.Fields.AddAsk(wrange, AddAskName, ref prompt, ref missing, ref askonce);
}
VBA Code :-
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, _
Name:="MiddleInitial"
C# Code :-
public void AddMailmergeFileds()
{
Word.Range wrange = ThisApplication.Selection.Range;
string AddAskName = "Aviansh";
ThisApplication.ActiveDocument.MailMerge.Fields.AddAsk(wrange, AddAskName, ref missing, ref missing, ref missing);
}
VBA Code :-
Sub MappedFields()
Dim intCount As Integer
Dim docCurrent As Document
Dim docNew As Document
On Error Resume Next
Set docCurrent = ThisDocument
Set docNew = Documents.Add
'Add leader tab to new document
docNew.Paragraphs.TabStops.Add _
Position:=InchesToPoints(3.5), _
Leader:=wdTabLeaderDots
With docCurrent.MailMerge.DataSource
'Insert heading paragraph for tabbed columns
docNew.Content.InsertAfter "Word Mapped Data Field" _
& vbTab & "Data Source Field"
Do
intCount = intCount + 1
'Insert Word mapped data field name and the
'corresponding data source field name
docNew.Content.InsertAfter .MappedDataFields( _
Index:=intCount).Name & vbTab & _
.MappedDataFields(Index:=intCount) _
.DataFieldName
'Insert paragraph
docNew.Content.InsertParagraphAfter
Loop Until intCount = .MappedDataFields.Count
End With
End Sub
C# Code :-
public void MappedFields()
{
int inCount = 0;
Word.Document docCurrent = null;
Word.Document docNew = null;
docCurrent = ThisApplication.ActiveDocument;
docNew = ThisApplication.Documents.Add(ref missing, ref missing, ref missing, ref missing);
object TabLeaderdots = Word.WdTabLeader.wdTabLeaderDots;
float Postion = 3.5f;
docNew.Paragraphs.TabStops.Add(Postion, ref missing, ref TabLeaderdots);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment