Name related procedures in class MailMergeDataSource (Word VBA)

This page presents procedures from class MailMergeDataSource related to the theme Name: FieldNames, HeaderSourceName, Name and TableName

FieldNames

Returns a MailMergeFieldNames collection that represents the names of all the fields in the specified mail merge data source.

For information about returning a single member of a collection, see Returning an object from a collection.

MsgBox ActiveDocument.MailMerge.DataSource.FieldNames(1).Name

HeaderSourceName

Returns the path and file name of the header source attached to the specified mail merge main document.

Dim strName As String 
 
strName = ActiveDocument.MailMerge.DataSource.HeaderSourceName 
If strName <> "" Then MsgBox strName

Name

Returns name of the specified object.

Dim strName As String
strName = ActiveDocument.MailMerge.DataSource.Name

TableName

Returns a String with the SQL query used to retrieve the records from the data source file attached to a mail merge document.

This property may be blank if the table name is unknown or not applicable to the current data source.

Sub DataSourceTable() 
 With ActiveDocument.MailMerge 
 If InStr(1, .DataSource.TableName, "Customers") < 1 Then 
 .OpenDataSource Name:="C:\ProgramFiles\Microsoft Office\Office\" & _ 
 "Samples\Northwind.mdb", LinkToSource:=True, _ 
 AddToRecentFiles:=False, Connection:="TABLE Customers" 
 End If 
 End With 
End Sub