Jay Bren
asked on
VBA Macro to convert thousands of .doc files to .docx (Word 2011 for Mac)
Hello,
I need a VBA Macro for Microsoft Word 2011 (Mac) that converts thousands of files in a given folder from .doc format to .docx format. The converted .docx files must be in full, true XML format (not "Compatibility Mode"). The script must cycle through the folder, converting 1 (one) file at a time, until all files have been converted. The faster, the better. There are 3 (three) additional requirements:
1. The macro must convert without prompting -- or skip -- any one of the .doc files that does not have recognizable encoding.
2. Formatting, tables, images, lists, etc. must not be lost upon conversion.
3. I need very specific, step-by-step instructions on exactly how to install and use it, because I have zero experience with that.
I need a VBA Macro for Microsoft Word 2011 (Mac) that converts thousands of files in a given folder from .doc format to .docx format. The converted .docx files must be in full, true XML format (not "Compatibility Mode"). The script must cycle through the folder, converting 1 (one) file at a time, until all files have been converted. The faster, the better. There are 3 (three) additional requirements:
1. The macro must convert without prompting -- or skip -- any one of the .doc files that does not have recognizable encoding.
2. Formatting, tables, images, lists, etc. must not be lost upon conversion.
3. I need very specific, step-by-step instructions on exactly how to install and use it, because I have zero experience with that.
ASKER
@strung: I already tried the demo of that software. It is useless because the new .docx files lost most formatting and all tables, images, lists, etc.
Have you seen this article about a Microsoft tool to do the conversion?
https://blogs.msdn.microsoft.com/ericwhite/2008/09/18/bulk-convert-doc-to-docx/
https://blogs.msdn.microsoft.com/ericwhite/2008/09/18/bulk-convert-doc-to-docx/
ASKER
@strung: I need a Mac-specific Macro. About 95% of the so-called "solutions" online were written for Windows (and almost all of them are very outdated).
You might be able to use an AppleScript and modify the doc/docx to pdf on the following pages.
https://onabai.wordpress.com/2012/07/10/convert-word-files-docdocx-to-pdf-in-osx/
http://hints.macworld.com/article.php?story=20110605113316760
Possibly like this:
https://onabai.wordpress.com/2012/07/10/convert-word-files-docdocx-to-pdf-in-osx/
http://hints.macworld.com/article.php?story=20110605113316760
Possibly like this:
property theList : {"doc"}
on run {input, parameters}
set output to {}
tell application "Microsoft Word" to set theOldDefaultPath to get default file path file path type documents path
repeat with x in input
try
set theDoc to contents of x
tell application "Finder"
set theFilePath to container of theDoc as text
set ext to name extension of theDoc
if ext is in theList then
set theName to name of theDoc
copy length of theName to l
copy length of ext to exl
set n to l - exl - 1
copy characters 1 through n of theName as string to theFilename
set theFilename to theFilename & ".doc"
tell application "Microsoft Word"
set default file path file path type documents path path theFilePath
open theDoc
set theActiveDoc to the active document
save as theActiveDoc file format format DOCX file name theFilename
copy (POSIX path of (theFilePath & theFilename as string)) to end of output
close theActiveDoc
end tell
end if
end tell
end try
end repeat
tell application "Microsoft Word" to set default file path file path type documents path path theOldDefaultPath
return output
end run
ASKER
@serialband: It works like a charm for converting batches of .doc to .pdf, without losing any formatting. However, when I try your edited version for .docx conversion, I get this error:
I see no reason why it wouldn't work if I can just figure out what , exactly, the "error" is and fix it. :)
The action “Run AppleScript” encountered an error.
I see no reason why it wouldn't work if I can just figure out what , exactly, the "error" is and fix it. :)
Shouldn't the line
set theFilename to theFilename & ".doc"
read
set theFilename to theFilename & ".docx"
?
set theFilename to theFilename & ".doc"
read
set theFilename to theFilename & ".docx"
?
Here is another alternative script: https://discussions.apple.com/thread/3026861?tstart=0
ASKER
Yes, @strung, I believe that @serialband meant to type ".docx". I changed it to ".docx" for my testing, but I received the same error message.
Have you tried stepping through the script to see what line generates the error?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.macworld.com/article/1160591/batchdocx.html
http://docxtodoc.net