Sometimes I find that it’s useful to save my Word documents as PDFs.
After playing around with the Save As PDF plugin for Office, I decided that it would be cool if I could write a script to convert a job lot of Word documents.
MS Word 2007
Save As PDF Office 2007 Plugin
Just copy and paste the code into Notepad and save the file as
WordToPDF.vbs on your desktop.
<code>'Word to PDF
'By John Reid
'(c) 2007 bloggingIT - http://www.maxpower.plus.com
'Feel free to use, modify, and redistribute - just leave the credits intact
'Quick Export to PDF
Const wdExportAllDocument = 0
Const wdExportOptimizeForPrint = 0
Const wdExportDocumentContent = 0
Const wdExportFormatPDF = 17
Const wdExportCreateHeadingBookmarks = 1
if Wscript.Arguments.Count > 0 Then
'Fire up MS Word 2007
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWord = CreateObject("Word.Application")
'Enumerate the passed in file names
For i = 0 to wscript.arguments.count - 1
Set objFile = objFSO.GetFile(WScript.Arguments(i))
Set objDoc = objWord.Documents.Open(WScript.Arguments(i),,TRUE)
dirPath = objFSO.GetParentFolderName(objFile)
fileBaseName = objFSO.GetBaseName(objFile)
'Export to PDF using preferred settings
pdf = objWord.ActiveDocument.ExportAsFixedFormat _
(dirPath & "\" & fileBaseName & ".pdf", _
wdExportFormatPDF, False, wdExportOptimizeForPrint, _
False, True, _
'Quit MS Word
msgbox("You must select a file to convert")
When you find a document that you wish to convert, just drag and drop the file onto the script.
Right, there’s an Excel version along shortly.
I recently downloaded the Office 2007 Trial to replace the buggy BETA 2 Technical Refresh that I had. I’ve encountered some issues that others probably will, and a few workarounds.
- Cannot open files saved in BETA 2 with the Office Compatibility Pack
This is not strictly an issue with using the trial software, but it is relevant if upgrading from BETA 2. The issue is that you cannot use the final conversion pack to open Office 2007 BETA 2 documents. The only way around this is to open and save any Office documents that you have created with BETA 2.
- Cannot download the Save As PDF or XPS plugin
The plugin can only be downloaded if you have a fully licenced version of Office installed on your computer to authenticate with the Office Genuine Advantage requirement. This was a nuisance to me as I’d quite happily been exporting PDFs in Office for some time.
Anyway, the trick is that you can download the Save As PDF or XPS tool with any version of Office installed as long is it passes validation. I used a computer with Office 2003 installed to download the plugin. Just copy the installer to the Office 2007 Trial that you wish you install it on and install.
- You get an error telling you that you need to uninstall Office 2007 prerelease versions and cannot upgrade.
In fact, the error is
The 2007 Microsoft Office system does not support upgrading from a prerelease version of the 2007 Microsoft Office system. You must first uninstall any prerelease versions of the 2007 Microsoft Office system products and associated technologies.
Correct the issue(s) listed above and re-run setup.
If you’re like me, you probably became quickly frustrated with the fact that you HAD uninstalled every component of Office 2007 BETA 2 already. There is a knowledgebase article which goes through the registry and other long-winded methods, but it’s much simpler to download MyUninstaller from NirSoft.
Run MyUninstaller, and you will probably see some leftover Office 2007 MUL Packs. Uninstall everything related to Office 2007, and restart the Office 2007 Final installation. It should run through without a hitch.
Thought that I’d test out the blogging capabilities of Word 2007 BETA 2.
I know that a lot of people have already been through this, but I’ve had trouble bringing myself to believe that it might actually work ok.
So this is it. Done in Word. Running Vista RC1 which I just managed to download. Exciting, eh?