This documentation is archived and is not being maintained.

Document.SaveAs Method

Saves the document with a new name or format. Some of the arguments for this method correspond to the options in the Save As dialog box.

Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word (in

public virtual void SaveAs (
	[OptionalAttribute] ref Object FileName,
	[OptionalAttribute] ref Object FileFormat,
	[OptionalAttribute] ref Object LockComments,
	[OptionalAttribute] ref Object Password,
	[OptionalAttribute] ref Object AddToRecentFiles,
	[OptionalAttribute] ref Object WritePassword,
	[OptionalAttribute] ref Object ReadOnlyRecommended,
	[OptionalAttribute] ref Object EmbedTrueTypeFonts,
	[OptionalAttribute] ref Object SaveNativePictureFormat,
	[OptionalAttribute] ref Object SaveFormsData,
	[OptionalAttribute] ref Object SaveAsAOCELetter,
	[OptionalAttribute] ref Object Encoding,
	[OptionalAttribute] ref Object InsertLineBreaks,
	[OptionalAttribute] ref Object AllowSubstitutions,
	[OptionalAttribute] ref Object LineEnding,
	[OptionalAttribute] ref Object AddBiDiMarks



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 file name already exists, the document is overwritten without the user being prompted first.


The format in which the document is saved. Can be any WdSaveFormat value. To save a document in another format, specify the appropriate value for the SaveFormat property.


true to lock the document for comments. The default is false.


A password string for opening the document. (See Remarks below.)


true to add the document to the list of recently used files on the File menu. The default is true.


A password string for saving changes to the document. (See Remarks below.)


true to have Microsoft Office Word suggest read-only status whenever the document is opened. The default is false.


true to save TrueType fonts with the document. If omitted, the EmbedTrueTypeFonts argument assumes the value of the EmbedTrueTypeFonts property.


If graphics were imported from another platform (for example, Macintosh), true to save only the Windows version of the imported graphics.


true to save the data entered by a user in a form as a data record.


If the document has an attached mailer, true to save the document as an AOCE letter (the mailer is saved).


MsoEncoding. The code page, or character set, to use for documents saved as encoded text files. The default is the system code page.


If the document is saved as a text file, true to insert line breaks at the end of each line of text.


If 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.


The way Word marks the line and paragraph breaks in documents saved as text files. Can be any WdLineEndingType value.


true adds control characters to the output file to preserve bi-directional layout of the text in the original document.

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.

Optional Parameters

For information on optional parameters, see Understanding Optional Parameters in COM Interop.

The following code example uses the SaveAs method to save the document in RTF format using the new file name myfile.doc.

private void DocumentSaveAs()
    object FileName = "myfile.doc";
    object FileFormat = Word.WdSaveFormat.wdFormatRTF;
    object LockComments = false;
    object AddToRecentFiles = true;
    object ReadOnlyRecommended = false;
    object EmbedTrueTypeFonts = false;
    object SaveNativePictureFormat = true;
    object SaveFormsData = true;
    object SaveAsAOCELetter = false;
    object Encoding = Office.MsoEncoding.msoEncodingUSASCII;
    object InsertLineBreaks = false;
    object AllowSubstitutions = false;
    object LineEnding = Word.WdLineEndingType.wdCRLF;
    object AddBiDiMarks = false;

    if (this.SaveFormat == (int)Word.WdSaveFormat.wdFormatDocument)
        this.SaveAs(ref FileName, ref FileFormat, ref LockComments,
            ref missing, ref AddToRecentFiles, ref missing,
            ref ReadOnlyRecommended, ref EmbedTrueTypeFonts,
            ref SaveNativePictureFormat, ref SaveFormsData,
            ref SaveAsAOCELetter, ref Encoding, ref InsertLineBreaks,
            ref AllowSubstitutions, ref LineEnding, ref AddBiDiMarks);