You need to convert a Word document to the OOXML Strict format but cannot use the Save As dialog for every file. OOXML Strict is the ISO-standard version of the Office Open XML format, which ensures cross-platform compatibility and long-term archival compliance. This article explains how to automate the conversion using VBA macros, PowerShell with the Open XML SDK, and the Office COM object model. You will learn the exact code and steps to convert single or batch documents without manual intervention.
Key Takeaways: Automating OOXML Strict Conversion
- VBA macro with FileFormat:=wdFormatXMLStrictDocument: Converts the active document to OOXML Strict in one line of code.
- PowerShell + Open XML SDK 2.5: Enables headless conversion on servers without Word installed using the DocumentFormat.OpenXml.Packaging namespace.
- Batch processing via folder loop: Use Dir() in VBA or Get-ChildItem in PowerShell to convert all .docx files in a folder.
What Is OOXML Strict and Why Convert Programmatically
OOXML Strict is the ISO 29500:2008 standard version of the Office Open XML format. The default .docx format in Word uses a transitional variant that includes legacy binary features not part of the ISO standard. OOXML Strict removes those legacy elements, producing a file that is fully compliant with the international standard.
Converting programmatically is necessary when you must process hundreds or thousands of files. Manual conversion through File > Save As > Browse > Save as type > Word Document (docx) with the “Strict” option selected is impractical for batch work. Automation also ensures consistent output — every converted file uses the same settings, reducing human error.
Prerequisites for Each Method
The VBA method requires Word installed on the machine. The PowerShell method requires the Open XML SDK 2.5 for Microsoft Office, which can be installed via NuGet or the Microsoft Download Center. The COM method also requires Word installed but runs outside the Word GUI, which is useful for server-side automation where no interactive session exists.
Method 1: Convert Using a VBA Macro
This method works inside Word. You run a macro that saves the current document in OOXML Strict format. The macro uses the wdFormatXMLStrictDocument constant, which has a value of 24.
- Open the Visual Basic Editor
Press Alt+F11. In the Project Explorer, double-click ThisDocument or insert a new module via Insert > Module. - Paste the conversion macro
Copy and paste the following code into the module:Sub ConvertToOOXMLStrict()Dim doc As DocumentSet doc = ActiveDocumentDim newName As StringnewName = Replace(doc.FullName, ".docx", "_strict.docx")doc.SaveAs2 FileName:=newName, FileFormat:=wdFormatXMLStrictDocumentEnd Sub - Run the macro
Press F5 while the cursor is inside the macro. A new file namedoriginal_strict.docxis saved in the same folder. - Batch convert all documents in a folder
Use this macro to process every .docx file in a folder:Sub BatchConvertToStrict()Dim f As String, doc As Documentf = Dir("C:\Docs\docx")Do While f <> ""Set doc = Documents.Open("C:\Docs\" & f)doc.SaveAs2 FileName:="C:\Docs\Strict\" & f, FileFormat:=wdFormatXMLStrictDocumentdoc.Closef = DirLoopEnd Sub
Change the folder paths to match your environment.
Method 2: Convert Using PowerShell and Open XML SDK
This method does not require Word to be installed. It uses the DocumentFormat.OpenXml.Packaging namespace to change the file format programmatically. The SDK reads the document, changes its package type to Strict, and saves it.
- Install the Open XML SDK
Run this command in an elevated PowerShell console:Install-Package OpenXmlSdk -ProviderName NuGet
Alternatively, download the SDK from Microsoft and install it manually. - Create the conversion script
Save the following asConvertToStrict.ps1:Add-Type -Path "C:\Program Files\Open XML SDK\V2.5\lib\DocumentFormat.OpenXml.dll"$source = "C:\Docs\report.docx"$destination = "C:\Docs\report_strict.docx"$doc = [DocumentFormat.OpenXml.Packaging.WordprocessingDocument]::Open($source, $false)$doc.ChangeDocumentType([DocumentFormat.OpenXml.WordprocessingDocumentType]::Strict)$doc.SaveAs($destination)$doc.Dispose() - Run the script
Open PowerShell as Administrator and execute:powershell -ExecutionPolicy Bypass -File ConvertToStrict.ps1
The output file is saved in the destination path. - Batch convert all .docx files in a folder
Wrap the conversion in a loop:$files = Get-ChildItem "C:\Docs" -Filter docxforeach ($f in $files) {$doc = [DocumentFormat.OpenXml.Packaging.WordprocessingDocument]::Open($f.FullName, $false)$doc.ChangeDocumentType([DocumentFormat.OpenXml.WordprocessingDocumentType]::Strict)$out = Join-Path "C:\Docs\Strict" $f.Name$doc.SaveAs($out)$doc.Dispose()}
Method 3: Convert Using the COM Object Model (Word Not Visible)
This method uses Word’s COM interface but keeps the application hidden. It is suitable for server-based automation where you need Word’s full rendering capabilities but do not want a visible window.
- Create a PowerShell script using COM
Save the following asConvertViaCOM.ps1:$word = New-Object -ComObject Word.Application$word.Visible = $false$doc = $word.Documents.Open("C:\Docs\report.docx")$doc.SaveAs2("C:\Docs\report_strict.docx", [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatXMLStrictDocument)$doc.Close()$word.Quit() - Run the script
Execute in PowerShell:powershell -ExecutionPolicy Bypass -File ConvertViaCOM.ps1
Word opens briefly in the background, converts the file, and closes. - Batch conversion with COM
Loop through all .docx files:$word = New-Object -ComObject Word.Application$word.Visible = $false$files = Get-ChildItem "C:\Docs" -Filter docxforeach ($f in $files) {$doc = $word.Documents.Open($f.FullName)$out = Join-Path "C:\Docs\Strict" $f.Name$doc.SaveAs2($out, [Microsoft.Office.Interop.Word.WdSaveFormat]::wdFormatXMLStrictDocument)$doc.Close()}$word.Quit()
Common Conversion Errors and Limitations
“The file format is not supported” error in PowerShell SDK method
This occurs when the source file is not a valid .docx file. The SDK can only open OPC-based packages. Corrupted files or those saved in .doc format will fail. Verify the file extension and repair the document first using Word’s Open and Repair feature.
VBA macro fails with “Permission denied”
The macro cannot write to a read-only location or a folder where the user lacks write permissions. Ensure the output folder allows write access. Use an absolute path like C:\Users\YourName\Documents\Strict\ instead of a system-protected folder.
COM method leaves Word.exe processes running
If the script crashes before calling $word.Quit(), a Word process remains in memory. Always wrap the COM operations in a try-catch-finally block, or use Stop-Process -Name WINWORD after the script completes. For production scripts, use the System.Runtime.InteropServices.Marshal.ReleaseComObject method to cleanly release the COM object.
OOXML Strict files open in older versions of Word
Word 2007 and earlier do not support OOXML Strict natively. Users with these versions will see a compatibility warning or may be unable to open the file. If backward compatibility is required, stick with the transitional .docx format.
VBA vs PowerShell vs COM: Automation Method Comparison
| Item | VBA Macro | PowerShell + SDK | COM Object |
|---|---|---|---|
| Requires Word installed | Yes | No | Yes |
| Requires Open XML SDK | No | Yes | No |
| Runs headless (no GUI) | No (Word visible) | Yes | Yes |
| Batch conversion speed | Slow (opens each doc) | Fast (no Word load) | Moderate |
| Handles complex formatting | Full fidelity | May lose some features | Full fidelity |
| Best for | Ad-hoc single files | Server automation | Server with Word license |
You can now convert Word documents to OOXML Strict format programmatically using VBA, PowerShell with the Open XML SDK, or the COM object model. Choose the method that matches your environment: VBA for interactive use, SDK for headless servers, and COM when full Word fidelity is needed on a server. As a next step, test each method on a single file before running a batch. An advanced tip: use the SDK method to validate the output by checking the DocumentType property — it should return Strict after conversion.