views:

37

answers:

1

A template report with extension *.docm will be shown to user, he will modify it, and when he click the save button. I want to write the modified the document as accessionID.docm at the specified folder. What must be the object 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);
    }
}
+1  A: 

Use

Word.WdSaveFormat.wdFormatXMLDocumentMacroEnabled

if you want to get a macro-enabled document.

0xA3
I have included namespace using Microsoft.Office.Interop.Word;However WdSaveFormat does not include the wdFormatXMLDocumentMacroEnabled ? why could it be?
anarhikos
@anarhikos: To have this value available, you need Word 2007 or later, and you should make sure that you added a reference to the correct version of `Microsoft.Office.Interop.Word` (12.0 or later) to your project.
0xA3
I've version 11.0I hope version 12 will handle my problem thanks for answer brother
anarhikos