SaveAs Method

Applies To

Document object.

Description

Saves the specified document with a new name or format. The arguments for this method correspond to the options in the Save As dialog box (File menu).

Syntax

expression.SaveAs(FileName, FileFormat, LockComments, Password,
ú AddToRecentFiles, WritePassword, ReadOnlyRecommended,
ú EmbedTrueTypeFonts, SaveNativePictureFormat, SaveFormsData,
ú SaveAsAOCELetter)

expression Required. An expression that returns a Document object.

FileName Optional Variant. The name for the document. The default is the current folder and file name. If the document has never been saved, the default name is used (for example, Doc1.doc). If a document with the specified FileName already exists, the document is overwritten without the user being prompted first.

FileFormat Optional Variant. The format in which the document is saved. Can be one of the following WdSaveFormat constants: wdFormatDocument, wdFormatDOSText, wdFormatDOSTextLineBreaks, wdFormatRTF, wdFormatTemplate, wdFormatText, wdFormatTextLineBreaks, or wdFormatUnicodeText. To save a document in another format, specify the appropriate value for the SaveFormat property of the FileConverter object.

LockComments Optional Variant. True to lock the document for comments.

Password Optional Variant. A password string for opening the document.

AddToRecentFiles Optional Variant. True to add the document to the list of recently used files on the File menu.

WritePassword Optional Variant. A password string for saving changes to the document.

ReadOnlyRecommended Optional Variant. True to have Word suggest read-only status whenever the document is opened.

EmbedTrueTypeFonts Optional Variant. True to save TrueType fonts with the document.

SaveNativePictureFormat Optional Variant. If graphics were imported from another platform (Macintosh), True to save only the Windows version of the imported graphics.

SaveFormsData Optional Variant. True to save the data entered by a user in a form as a data record.

SaveAsAOCELetter Optional Variant. If the document has an attached mailer, True to save the document as an AOCE letter (the mailer is saved).

See Also

Close method, DefaultSaveFormat property, Save method, Saved property, SaveFormat property.

Example

This example saves the active document as Test.rtf in rich-text format (RTF).

ActiveDocument.SaveAs FileName:="Text.rtf", FileFormat:=wdFormatRTF
This example saves the active document in text-file format, with the file name extension ".txt".

myDocname = ActiveDocument.Name
pos = InStr(myDocname, ".")
If pos > 0 Then
    myDocname = Left(myDocname, pos - 1)
    myDocname = myDocname & ".txt"
    ActiveDocument.SaveAs FileName:=myDocname, FileFormat:=wdFormatText
End If
This example retrieves the SaveFormat property value for the WordPerfect 6.x converter, and then it uses this value with the SaveAs method.

formatNum = FileConverters("WordPerfect6x").SaveFormat
Documents(1).SaveAs FileName:="Hello.wp", FileFormat:=formatNum
This example saves MyDoc.doc with a write password and then closes the document.

With Documents("MyDoc.doc")
    .SaveAs WritePassword:="pass"
    .Close
End With