This documentation is archived and is not being maintained.

Document.SaveAs Method

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


expression.SaveAs(FileName, FileFormat, LockComments, Password, AddToRecentFiles, WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts, SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter, Encoding, InsertLineBreaks, AllowSubstitutions, LineEnding, AddBiDiMarks)

expression   Required. A variable that represents a Document object.


NameRequired/OptionalData TypeDescription
FileNameOptionalVariantThe 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 file name already exists, the document is overwritten without the user being prompted first.
FileFormatOptionalVariantThe format in which the document is saved. Can be any WdSaveFormat constant. To save a document in another format, specify the appropriate value for the SaveFormat property of the FileConverter object.
LockCommentsOptionalVariantTrue to lock the document for comments. The default is False.
PasswordOptionalVariantA password string for opening the document. (See Remarks below.)
AddToRecentFilesOptionalVariantTrue to add the document to the list of recently used files on the File menu. The default is True.
WritePasswordOptionalVariantA password string for saving changes to the document. (See Remarks below.)
ReadOnlyRecommendedOptionalVariantTrue to have Microsoft Office Word suggest read-only status whenever the document is opened. The default is False.
EmbedTrueTypeFontsOptionalVariantTrue to save TrueType fonts with the document. If omitted, the EmbedTrueTypeFonts argument assumes the value of the EmbedTrueTypeFonts property.
SaveNativePictureFormatOptionalVariantIf graphics were imported from another platform (for example, Macintosh), True to save only the Microsoft Windows version of the imported graphics.
SaveFormsDataOptionalVariantTrue to save the data entered by a user in a form as a record.
SaveAsAOCELetterOptionalVariantIf the document has an attached mailer, True to save the document as an AOCE letter (the mailer is saved).
EncodingOptionalMsoEncodingThe code page, or character set, to use for documents saved as encoded text files. The default is the system code page. You cannot use all MsoEncoding constants with this parmeter.
InsertLineBreaksOptionalVariantIf the document is saved as a text file, True to insert line breaks at the end of each line of text.
AllowSubstitutionsOptionalVariantIf the document is saved as a text file, True allows Word to replace some symbols with text that looks similar. For example, displaying the copyright symbol as (c). The default is False.
LineEndingOptionalVariantThe way Word marks the line and paragraph breaks in documents saved as text files. Can be one of the following WdLineEndingType constants: wdCRLF (default) or wdCROnly.
AddBiDiMarksOptionalVariantTrue adds control characters to the output file to preserve bi-directional layout of the text in the original document.


You can save as a PDF or XPS file from a 2007 Microsoft Office system program only after you install an add-in. For more information, search for "Enable support for other file formats, such as PDF and XPS" on Office Online.


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. For recommended best practices on how to do this, see Security Notes for Microsoft Office Solution Developers.


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

Visual Basic for Applications
Sub SaveAsRTF()
    ActiveDocument.SaveAs FileName:="Text.rtf", _
End Sub

This example saves the active document in text-file format with the extension ".txt".

Visual Basic for Applications
Sub SaveAsTextFile()
    Dim strDocName As String
    Dim intPos As Integer

    'Find position of extension in file name
    strDocName = ActiveDocument.Name
    intPos = InStrRev(strDocName, ".")

    If intPos = 0 Then

        'If the document has not yet been saved
        'Ask the user to provide a file name
        strDocName = InputBox("Please enter the name " & _
            "of your document.")

        'Strip off extension and add ".txt" extension
        strDocName = Left(strDocName, intPos - 1)
        strDocName = strDocName & ".txt"
    End If

    'Save file with new extension
    ActiveDocument.SaveAs FileName:=strDocName, _
End Sub

This example loops through all the installed converters and, if it finds the WordPerfect 6.0 converter, it saves the active document using the converter.

Visual Basic for Applications
Sub SaveWithConverter()

    Dim cnvWrdPrf As FileConverter

    'Look for WordPerfect file converter
    'And save document using the converter
    'For the FileFormat converter value
    For Each cnvWrdPrf In Application.FileConverters
        If cnvWrdPrf.ClassName = "WrdPrfctWin" Then
            ActiveDocument.SaveAs FileName:="MyWP.doc", _
        End If
    Next cnvWrdPrf

End Sub

This example illustrates a procedure that saves a document with a password.

Visual Basic for Applications
Sub SaveWithPassword(docCurrent As Document, strPWD As String)
    With docCurrent
        .SaveAs WritePassword:=strPWD
    End With
End Sub