CreateNewDocument Method

Microsoft Word Visual Basic

Creates a new label document using either the default label options or ones that you specify. Returns a Document object that represents the new document.

expression.CreateNewDocument(Name, Address, AutoText, ExtractAddress, LaserTray, PrintEPostageLabel, Vertical)

expression    Required. An expression that returns one of the above objects.

Name   Optional Variant. The mailing label name.

Address   Optional Variant. The text for the mailing label.

AutoText   Optional Variant. The name of the AutoText entry that includes the mailing label text.

ExtractAddress   Optional Variant. True to use the address text marked by the user-defined bookmark named "EnvelopeAddress" instead of using the Address argument.

LaserTray    Optional Variant. The laser printer tray. Can be one of the following WdPaperTray constants.

WdPaperTray can be any one of the following WdPaperTray constants:
wdPrinterAutomaticSheetFeed
wdPrinterDefaultBin
wdPrinterEnvelopeFeed
wdPrinterFormSource
wdPrinterLargeCapacityBin
wdPrinterLargeFormatBin
wdPrinterLowerBin
wdPrinterManualFeed
wdPrinterManualEnvelopeFeed
wdPrinterMiddleBin
wdPrinterOnlyBin
wdPrinterPaperCassette
wdPrinterSmallFormatBin
wdPrinterTractorFeed
wdPrinterUpperBin

PrintEPostageLabel   Optional Variant. True to print postage using an Internet e-postage vendor.

Vertical   Optional Variant. True formats text vertically on the label. Used for Asian-language mailing labels.

ShowCreateNewDocument method as it applies to the Hyperlink object.

Creates a new document linked to the specified hyperlink.

expression.CreateNewDocument(FileName, EditNow, Overwrite)

expression    Required. An expression that returns one of the above objects.

FileName   Required String. The file name of the specified document.

EditNow   Required Boolean. True to have the specified document open immediately in its associated editing environment. The default value is True.

Overwrite   Required Boolean. True to overwrite any existing file of the same name in the same folder. False if any existing file of the same name is preserved and the FileName argument specifies a new file name. The default value is False.

Example

ShowAs it applies to the MailingLabel object.

This example creates a new Avery 2160 minilabel document using a predefined address.

addr = "Dave Edson" & vbCr & "123 Skye St." _
    & vbCr & "Our Town, WA 98004"
Application.MailingLabel.CreateNewDocument _
    Name:="2160 mini", Address:=addr, ExtractAddress:=False
				

This example creates a new Avery 5664 shipping-label document using the selected text as the address.

addr = Selection.Text
Application.MailingLabel.CreateNewDocument _
    Name:="5664", Address:=addr, _
    LaserTray:=wdPrinterUpperBin
				

This example creates a new self-adhesive-label document using the EnvelopeAddress bookmark text as the address.

If ActiveDocument.Bookmarks.Exists("EnvelopeAddress") = True Then
    Application.MailingLabel.CreateNewDocument _
        Name:="Self Adhesive Tab 1 1/2""", ExtractAddress:=True
End If
				

ShowAs it applies to the Hyperlink object.

This example creates a new document based on the new hyperlink in the first document and then loads the new document into Microsoft Word for editing. The document is called “Overview.doc,” and it overwrites any file of the same name in the \\Server1\Annual folder.

With Documents(1)
    Set objHyper = _
        .Hyperlinks.Add(Anchor:=Selection.Range, _
        Address:="\\Server1\Annual\Overview.doc")
    objHyper.CreateNewDocument _
        FileName:="\\Server1\Annual\Overview.doc", _
        EditNow:=True, Overwrite:=True
End With