Document.SaveAs2 方法

使用新名稱或新格式儲存文件。 此方法的部分引數對應到 [另存新檔] 對話方塊中的選項。

命名空間:  Microsoft.Office.Tools.Word
組件:   Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)
  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
Sub SaveAs2 ( _
    ByRef FileName As Object, _
    ByRef FileFormat As Object, _
    ByRef LockComments As Object, _
    ByRef Password As Object, _
    ByRef AddToRecentFiles As Object, _
    ByRef WritePassword As Object, _
    ByRef ReadOnlyRecommended As Object, _
    ByRef EmbedTrueTypeFonts As Object, _
    ByRef SaveNativePictureFormat As Object, _
    ByRef SaveFormsData As Object, _
    ByRef SaveAsAOCELetter As Object, _
    ByRef Encoding As Object, _
    ByRef InsertLineBreaks As Object, _
    ByRef AllowSubstitutions As Object, _
    ByRef LineEnding As Object, _
    ByRef AddBiDiMarks As Object, _
    ByRef CompatibilityMode As Object _
)
void SaveAs2(
    ref Object FileName,
    ref Object FileFormat,
    ref Object LockComments,
    ref Object Password,
    ref Object AddToRecentFiles,
    ref Object WritePassword,
    ref Object ReadOnlyRecommended,
    ref Object EmbedTrueTypeFonts,
    ref Object SaveNativePictureFormat,
    ref Object SaveFormsData,
    ref Object SaveAsAOCELetter,
    ref Object Encoding,
    ref Object InsertLineBreaks,
    ref Object AllowSubstitutions,
    ref Object LineEnding,
    ref Object AddBiDiMarks,
    ref Object CompatibilityMode
)

參數

  • FileName
    型別:System.Object%
    文件的名稱。預設為目前的資料夾和檔案名稱。如果未曾儲存過文件,就會使用預設名稱 (例如 Doc1.doc)。如果指定檔名的文件已存在,並不會先提示使用者,而是直接覆寫文件。
  • FileFormat
    型別:System.Object%
    儲存文件的格式。可以是任何的 WdSaveFormat 值。若要使用其他格式儲存文件,請指定適用於 SaveFormat 屬性的值。
  • LockComments
    型別:System.Object%
    true 表示鎖定文件的註解。預設值為 false。
  • Password
    型別:System.Object%
    開啟文件的密碼字串。請參閱下方註解。
  • AddToRecentFiles
    型別:System.Object%
    true 表示將文件加入至 [檔案] 功能表上最近使用檔案的清單。預設值為 true。
  • WritePassword
    型別:System.Object%
    將變更儲存至文件的密碼。請參閱下方註解。
  • ReadOnlyRecommended
    型別:System.Object%
    true 表示每次開啟文件時,Microsoft Office Word 都會建議採取唯讀狀態。預設值為 false。
  • EmbedTrueTypeFonts
    型別:System.Object%
    true 表示隨文件一併儲存 TrueType 字型。如果省略,則 EmbedTrueTypeFonts 引數會假設 EmbedTrueTypeFonts 屬性的值。
  • SaveNativePictureFormat
    型別:System.Object%
    如果從其他平台 (例如 Macintosh) 匯入圖形,true 表示只儲存 Windows 版本的已匯入圖形。
  • SaveFormsData
    型別:System.Object%
    true 表示將使用者輸入至表單的資料儲存為資料錄。
  • SaveAsAOCELetter
    型別:System.Object%
    如果文件已附加寄件者,true 表示將文件儲存為 AOCE 信件 (已儲存寄件者)。
  • Encoding
    型別:System.Object%
    MsoEncoding.用來將文件儲存為已編碼文字檔的字碼頁或字元集。預設為系統字碼頁。
  • InsertLineBreaks
    型別:System.Object%
    如果將文件儲存為文字檔,true 表示在每一行文字末端插入斷行符號。
  • AllowSubstitutions
    型別:System.Object%
    如果將文件儲存為文字檔,true 表示允許 Word 使用外觀相似的文字取代某些符號。例如,使用 (c) 代表版權符號。預設值為 false。
  • LineEnding
    型別:System.Object%
    在儲存為文字檔的文件中,Word 標示斷行符號和段落符號的方式。可以是任何的 WdLineEndingType 值。
  • AddBiDiMarks
    型別:System.Object%
    true 表示將控制字元加入至輸出檔,在原始文件中保留文字的雙向配置。
  • CompatibilityMode
    型別:System.Object%
    Microsoft.Office.Interop.Word.WdCompatibilityMode 的其中一個值指定 Word 2013 和 Word 2010 開啟文件時所用的相容性模式。

例外狀況

例外狀況 條件
MissingMemberException

這個方法用於 Word 2007 專案。

備註

避免在您的應用程式中使用固定編碼密碼。 如果程序中需要密碼,請向使用者要求密碼,並將密碼儲存在變數中,再將變數用於程式碼中。

注意事項注意事項

在以 .NET Framework 4 為目標的 Word 2007 專案中,此方法出現在 IntelliSense 中。不過,在 Word 2007 專案中無法使用此屬性。

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

.NET Framework 安全性

請參閱

參考

Document 介面

Microsoft.Office.Tools.Word 命名空間