20 September 2007

Batch converting Office 2007 documents to 2003 format


I had someone ask me today for a way to convert multiple docx files to plain old doc. Naturally I Googled for a solution (or should that be performed a web search using the Google™ search engine?) but I couldn't find one that I liked or was appropriate for someone a little less technically inclined. So I went ahead and rolled my own.

The result is a VBA macro enabled Word 2007 document. I have no idea if it works in any other versions of Word apart from the 2007 version although it might if the Compatibility Pack is installed. I do know that it probably won't work on anything apart from Windows because it expects folder names to end in a trailing backslash.

I should probably disclaim that I definitely am not responsible if this somehow messes something up. Use at your own risk! You can use this for whatever you like as long as you don't try to make money from it (not that you'd want to for this thing).

I should probably say that I hacked this together in a few minutes today. I've never used VBA before but take a look at the code if you want. You'll need to enable macros for this thing to work at all.

Download here!

4 comments:

Anonymous said...

thanks very useful.

Anonymous said...

Worked Perfectly!! Thank you so much!

Anonymous said...

worked for me too. Thanks

James Taylor said...

Thanks, works great, I copied your macros and document controls to two Excel 2007 macro enabled workbooks to convert .xlsx and .xlsm to .xls. I only had to change all occurrences of "ThisDocument." to "Me.", all ".docx" to ".xlsx" (".xlsm" in second workbook) and changed the following line:
.SaveAs Filename:=chosenFolder & Replace(currentFile, "xlsm", "xls"), FileFormat:=xlExcel9795

to
FileSaveAs chosenFolder & Replace(currentFile, "xlsm", "xls") ', FileFormat:=xlExcel9795

and added the FileSaveAs sub:

Sub FileSaveAs(strFileName)
' Save passed filename in Excel 97-2003 format
'
ActiveWorkbook.SaveAs Filename:= _
strFileName, FileFormat:=xlExcel8, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub

James Taylor jmtces@gmail.com

Post a Comment