Document.SaveAs方法?

时间:2010-08-05 13:43:49

标签: c# ms-word ms-office

将向用户显示扩展名为* .docm的模板报告,他将对其进行修改,并在单击“保存”按钮时显示。我想在指定的文件夹中将修改后的文档写为accessionID.docm。什么必须是对象FileFormat = ??

private void btnSaveDocument_Click(object sender, EventArgs e)
{
    if (m_docFileName == ReportWrite.m_templateReport)
    {
        m_docFileName = ReportWrite.m_accessionId.ToString();
        object FileName = RIS_CLIENT.Properties.Settings.Default.DownloadPath + "\\" + m_docFileName;
        object FileFormat = Word.WdSaveFormat.wdFormatRTF;
        object LockComments = false;
        object AddToRecentFiles = false;
        object ReadOnlyRecommended = false;
        object EmbedTrueTypeFonts = false;
        object SaveNativePictureFormat = true;
        object SaveFormsData = false;
        object SaveAsAOCELetter = false;
        object missing = false;

        objWinWordControl.document.SaveAs(
            ref FileName, 
            ref FileFormat, 
            ref LockComments,
            ref missing, 
            ref AddToRecentFiles, 
            ref missing,
            ref ReadOnlyRecommended, 
            ref EmbedTrueTypeFonts,
            ref SaveNativePictureFormat, 
            ref SaveFormsData,
            ref SaveAsAOCELetter);
    }
}

2 个答案:

答案 0 :(得分:3)

使用

Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled

如果您想获得启用宏的文档。

答案 1 :(得分:1)

Word.WdSaveFormat.wdFormatDocument;