ActiveDocument Property

Microsoft Publisher Visual Basic

object that represents the active publication. If there are no documents open, an error occurs.

expression.ActiveDocument

expression    Required. An expression that returns one of the objects in the Applies To list.

Example

This example allows the user to assign a file name to the active publication and save it with the new file name. The file name, along with other text, is then inserted after the currently selected text. (Note that Filename must be replacedvin with a valid publication name for this example to work.)

Sub NewsLetterSave()

    Dim strFileName As String

    ' Assign the explicit file name to a variable.
    strFileName = "Filename"
    Publisher.ActiveDocument.SaveAs strFileName

    ' Insert the file name and supporting text after selected text.
    Selection.TextRange.Collapse pbCollapseEnd
    Selection.TextRange = _
        " This publication has been saved as " & strFileName

End Sub