<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Convert a word processing document from the DOCM to the DOCX file format</title><link>https://sourceforge.net/p/asposeopenxml/wiki/Convert%2520a%2520word%2520processing%2520document%2520from%2520the%2520DOCM%2520to%2520the%2520DOCX%2520file%2520format/</link><description>Recent changes to Convert a word processing document from the DOCM to the DOCX file format</description><atom:link href="https://sourceforge.net/p/asposeopenxml/wiki/Convert%20a%20word%20processing%20document%20from%20the%20DOCM%20to%20the%20DOCX%20file%20format/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 26 May 2015 04:33:11 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/asposeopenxml/wiki/Convert%20a%20word%20processing%20document%20from%20the%20DOCM%20to%20the%20DOCX%20file%20format/feed.rss" rel="self" type="application/rss+xml"/><item><title>Convert a word processing document from the DOCM to the DOCX file format modified by Aspose Marketplace</title><link>https://sourceforge.net/p/asposeopenxml/wiki/Convert%2520a%2520word%2520processing%2520document%2520from%2520the%2520DOCM%2520to%2520the%2520DOCX%2520file%2520format/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -63,4 +63,4 @@

 ## Download ##

-* [Sample Code](https://sourceforge.net/p/asposeopenxml/code/ci/master/tree/Aspose.Words%20Vs%20OpenXML/ConvertFromDOCMtoDOCX)
+* [Sample Code](http://sourceforge.net/projects/asposeopenxml/files/Aspose.Words%20Vs%20OpenXML/ConvertFromDOCMtoDOCX.zip/download)
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aspose Marketplace</dc:creator><pubDate>Tue, 26 May 2015 04:33:11 -0000</pubDate><guid>https://sourceforge.net5d844d7c47f7072d5dd728022a07c3cb5fa69926</guid></item><item><title>Convert a word processing document from the DOCM to the DOCX file format modified by Aspose Marketplace</title><link>https://sourceforge.net/p/asposeopenxml/wiki/Convert%2520a%2520word%2520processing%2520document%2520from%2520the%2520DOCM%2520to%2520the%2520DOCX%2520file%2520format/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -63,4 +63,4 @@

 ## Download ##

-* [Sample Code]()
+* [Sample Code](https://sourceforge.net/p/asposeopenxml/code/ci/master/tree/Aspose.Words%20Vs%20OpenXML/ConvertFromDOCMtoDOCX)
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aspose Marketplace</dc:creator><pubDate>Tue, 26 May 2015 04:06:43 -0000</pubDate><guid>https://sourceforge.net67b8d53d6e1c57445307d78986f3c14ba7e3bcb2</guid></item><item><title>Convert a word processing document from the DOCM to the DOCX file format modified by Aspose Marketplace</title><link>https://sourceforge.net/p/asposeopenxml/wiki/Convert%2520a%2520word%2520processing%2520document%2520from%2520the%2520DOCM%2520to%2520the%2520DOCX%2520file%2520format/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The &lt;strong&gt;ConvertDOCMtoDOCX&lt;/strong&gt; sample method can be used to convert a Word 2010 or Word 2013 document that contains VBA code (and has a .docm extension) to a standard document (with a .docx extension). Use this method to remove the macros and the vbaProject part that contains them from a document stored in .docm file format.&lt;/p&gt;
&lt;h2 id="openxml-words"&gt;OpenXML Words&lt;/h2&gt;
&lt;p&gt;The sample code modifies the document that you specify, verifying that the document contains a vbaProject part, and deleting the part. After the code deletes the part, it changes the document type internally and renames the document so that it uses the .docx extension.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;    string fileName= "DOCMtoDOCX.docm";
    public static void ConvertDOCMtoDOCX(string fileName)
    {
        bool fileChanged = false;

        using (WordprocessingDocument document =
            WordprocessingDocument.Open(fileName, true))
        {
            // Access the main document part.
            var docPart = document.MainDocumentPart;

            // Look for the vbaProject part. If it is there, delete it.
            var vbaPart = docPart.VbaProjectPart;
            if (vbaPart != null)
            {
                // Delete the vbaProject part and then save the document.
                docPart.DeletePart(vbaPart);
                docPart.Document.Save();

                // Change the document type to
                // not macro-enabled.
                document.ChangeDocumentType(
                    WordprocessingDocumentType.Document);

                // Track that the document has been changed.
                fileChanged = true;
            }
        }

        // If anything goes wrong in this file handling,
        // the code will raise an exception back to the caller.
        if (fileChanged)
        {
            // Create the new .docx filename.
            var newFileName = Path.ChangeExtension(fileName, ".docx");

            // If it already exists, it will be deleted!
            if (File.Exists(newFileName))
            {
                File.Delete(newFileName);
            }

            // Rename the file.
            File.Move(fileName, newFileName);
        }
    }
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="asposewords"&gt;Aspose.Words&lt;/h2&gt;
&lt;p&gt;We can use &lt;strong&gt;Document&lt;/strong&gt; constructor of Aspose.Words API to load .doc or .docm files and use &lt;strong&gt;Document.Save&lt;/strong&gt; method to save to .docx.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;        Document doc = new Document(DOCMtoDOCX.docm);
        var newFileName = Path.ChangeExtension(fileName, ".docx");
        doc.Save(DOCMtoDOCX, SaveFormat.Docx);
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="download"&gt;Download&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="../"&gt;Sample Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aspose Marketplace</dc:creator><pubDate>Mon, 25 May 2015 19:31:25 -0000</pubDate><guid>https://sourceforge.net7dd1cdbde70b6c7b6b323ad666110afa3ef3d988</guid></item></channel></rss>