MailMerge.CreateHeaderSource Method

Creates a Microsoft Word document that stores a header record that's used in place of the data source header record in a mail merge.

Namespace:  Microsoft.Office.Interop.Word
Assembly:  Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)


Sub CreateHeaderSource ( _
    Name As String, _
    ByRef PasswordDocument As Object, _
    ByRef WritePasswordDocument As Object, _
    ByRef HeaderRecord As Object _
Dim instance As MailMerge
Dim Name As String
Dim PasswordDocument As Object
Dim WritePasswordDocument As Object
Dim HeaderRecord As Object

instance.CreateHeaderSource(Name, PasswordDocument, _
    WritePasswordDocument, HeaderRecord)
void CreateHeaderSource(
    string Name,
    ref Object PasswordDocument,
    ref Object WritePasswordDocument,
    ref Object HeaderRecord


  • Name
    Type: System.String
    Required String. The path and file name for the new header source.
  • PasswordDocument
    Type: System.Object%
    Optional Object. The password required to open the new header source.
  • WritePasswordDocument
    Type: System.Object%
    Optional Object. The password required to save changes to the new header source.
  • HeaderRecord
    Type: System.Object%
    Optional Object. A string that specifies the field names for the header record. If this argument is omitted, the standard header record is used: "Title, FirstName, LastName, JobTitle, Company, Address1, Address2, City, State, PostalCode, Country, HomePhone, WorkPhone." To separate field names in Windows, use the list separator specified in Regional Settings in Control Panel.


This method attaches the new header source to the specified document, which becomes a main document if it's not one already.

The new header source uses a table to arrange mail merge field names.

Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code.

See Also


MailMerge Interface

MailMerge Members

Microsoft.Office.Interop.Word Namespace