I have an ASP.NET application that uses Aspose.Words to create Microsoft Word documents. We recently upgraded to Office 2010 and now I want my application to create documents in Word 2010 format.
The application generated documents from macro enabled templates and I have converted all of them to Word 2010 .dotm format. I have also updated the application code that creates the documents to save them with an extension of .docm and I do specify .docm as the file format in the Save command.
This all seems to work fine. The ASP.NET application has a page with links on it to various documents that the users can click on and have the document open in Word 2010. The links are displayed in a datagrid. When this page is first loaded, as each item in the datagrid is databound, the user's role is checked and the protection of the document is updated to allow only specific users to update the document. If the user is not allowed to update the document, it is opened in protected, read-only mode. Here is the code snippet from the ITEMDATABOUND event of the datagrid that does this:
If InStr(CType(e.Item.FindControl("txtFileName"), TextBox).Text, ".docm") Then
Dim strFilePath as String = CType(e.Item.FindControl("txtFileName"), Textbox).Text)
Dim doc As Document = New Aspose.Words.Document(strFilePath)
If Session("StaffRole") = "PA" Then
If CType(e.Item.FindControl("chkFinal"), System.Web.UI.WebControls.CheckBox).Checked = True Then
doc.Save(strFilePath, SaveFormat.Docm) <== This statement
The problem is that the statement marked above doesn't seem to be saving the documents as 2010 .docm files because when I open the documents they open in Word 2010 in compability mode. If I run the templates outside of the ASP.NET application and create documents directly in Word 2010, everything is fine -- no compability mode. It's only when the above DOC.SAVE command is executed that the documents subsequently open in compability mode.
I tried commenting out the above doc.save statement and the documents subsequently opened cleanly not in compatibility mode. The documents are definitely saved as .docm files. When I go into the folder on the network drive where they are stored, they are listed as Microsoft Word Macro-Enabled Documents. But, I understand that Word 2007 also has macro-enabled .docm files and that the format is different from Word 2010 and that if you open a Word 2007 .docm document in Word 2010 it will open in compatibility mode.
Is the SaveFormat.Docm parameter of the Document.Save command for the Word 2007 .docm format? Is there another parameter value I should be using for Word 2010?
Thanks very much for any help you can give.