Automation: how to automate transforming .doc to .docx?
automation
Solution
Automate Word.
If you are using .NET, add Microsoft.Office.Interop.Word (make sure it is version 12 - equivalent to Word 2007 so you can achieve the above) reference assembly to your project and use it it automate word app to do exactly what you want to do above. The pseudocode
- Create the application object
- Use the application object to open a document (by supplying it the file name)
- Use the application object to perform SaveAs by supplying to it the format and output filename
- Close the current document
- Loop through the above till you finish with all documents
- Housekeeping code to release the Word or Doc objects
You can find plenty of example on google, just search for Word Automation in C# or something along that line.
Problem
I have a bunch of .doc files in a folder which I need to convert to .docx. To manually convert the .doc to .docx is pretty simple: - Open .doc in Word 2007 - Click on Save As... - Save it as .docx However, doing this for hundreds of files definitely ain't fun. =p How would you automate this?