Thread: [Solved] Save as PDF with bookmarks
View Single Post
 
Old 01-13-2017, 10:42 AM
rpatchet rpatchet is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jan 2017
Posts: 1
rpatchet is on a distinguished road
Default

I love your macro, I have been trying to do this for years on a huge Word document. And it worked great the first three times I used it. But the next day, the ExportAsFixedFormat fails with a read-only error. Running attrib from cmd.exe shows only the archive attribute set.

If I use ActiveDocument.SaveAs FileFormat:=wdFormatPDF (which does not let me select the PDF parameters, so it is unacceptable), the command fails and the VBA error dialog simply states that the command failed.

If I test for the existence of the file and try to delete it, the delete command fails and the VBA error dialog shows a permissions error.

I rebooted the computer to ensure no process had it locked. The Word document, macro, and PDF all exist in the same user account. When I do a File > Save As > PDF, Word prompts me to overwrite and then successfully writes the PDF.

I also encountered an odd problem with this macro. If I import the macro into a macro-free file, .docx, and run the macro, it works fine. If I save the document as a macro-enabled file, .docm, and run the macro, it fails.

Even more interesting: I deleted the PDF from the directory before I ran the macro and I still received the error "Run-time error '-2147467259 (80004005)': This file is read-only." I have no clue what file it thinks is read-only.
Reply With Quote