OpenHeaderSource Method

Microsoft Word Visual Basic

Show All

OpenHeaderSource Method

       

Attaches a mail merge header source to the specified document.

expression.OpenHeaderSource(Name, Format, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, OpenExclusive)

expression   Required. An expression that returns a MailMerge object.

Name   Required String. The file name of the header source.

Format   Optional Variant. The file converter used to open the document. Can be one of the following WdOpenFormat constants. To specify an external file format, use the OpenFormat property with a FileConverter object to determine the value to use with this argument.

WdOpenFormat can be one of these WdOpenFormat constants.
wdOpenFormatAllWord
wdOpenFormatAuto Default.
wdOpenFormatDocument
wdOpenFormatEncodedText
wdOpenFormatRTF
wdOpenFormatTemplate
wdOpenFormatText
wdOpenFormatUnicodeText
wdOpenFormatWebPages

ConfirmConversions   Optional Variant. True to display the Convert File dialog box if the file isn't in Word format.

ReadOnly   Optional Variant. True to open the header source on a read-only basis.

AddToRecentFiles   Optional Variant. True to add the file name to the list of recently used files at the bottom of the File menu.

PasswordDocument   Optional Variant. The password required to open the header source document.

PasswordTemplate   Optional Variant. The password required to open the header source template.

Revert   Optional Variant. Controls what happens if Name is the file name of an open document. True to discard any unsaved changes to the open document and reopen the file; False to activate the open document.

WritePasswordDocument   Optional Variant. The password required to save changes to the document data source.

WritePasswordTemplate   Optional Variant. The password required to save changes to the template data source.

OpenExclusive  Optional Variant. True to open exclusively.

Remarks

When a header source is attached, the first record in the header source is used in place of the header record in the data source.

Example

This example sets the active document as a main document for form letters, and then it attaches the header source named "Header.doc" and the data document named "Names.doc."

With ActiveDocument.MailMerge
    .MainDocumentType = wdFormLetters
    .OpenHeaderSource Name:="C:\Documents\Header.doc", _
         Revert:=False, AddToRecentFiles:=False
    .OpenDataSource Name:="C:\Documents\Names.doc"
End With