Loading word 2002 to PDF

EPamperin12

New Member
Joined
Jan 8, 2008
Messages
47
I'm using Word 2002 SP3 and Adobe Acrobat Professional 7.
I am trying to automate a save process that will create a PDF File.

The code below will create the Distiller File, however it will not run the distiller to complete the conversion to PDF.
I can manually go into the Distiller and click on the file and it creates the Pdf w/ the correct file name

I have already added the Acrobat Distiller, Create Adobe PDFMAker for Office and Adobe PDFMakerX to the Refereneces in VBA

Code:
Sub Create_PDF()
 
Dim tempPDFFileName As String
Dim tempPSFileName As String
Dim tempPDFRawFileName As String
Dim tempLogFileName As String
 
tempPDFRawFileName = ("H:\CreatePDF")
 
tempPSFileName = tempPDFRawFileName & ".ps"
tempPDFFileName = tempPDFRawFileName & ".pdf"
tempLogFileName = tempPDFRawFileName & ".log"
 
ActiveDocument.PrintOut OutputFileName:=tempPSFileName

Dim mypdfDist As New PdfDistiller

mypdfDist.FileToPDF tempPSFileName, tempPDFFileName, ""

Kill tempPSFileName
kill templogFileName
End Sub

I am getting a RunTime Error '-2147417851 (80010105)' Method 'FileToPDF' of object 'IPdfDistiller' failed.

Any help would be most appreciated.
-Eric
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi Eric,

That code looks familiar. It looks okay to me but have never tried it with Word so will need to test it first and I don't have Adobe at home.

One question...Do you have a an Adobe PDF in you list of available printers?

If nobody else has replied to you before Monday I'll have a look at it when I get to work.

Dom
 
Upvote 0
I'm getting some strange results with this and just not sure why.

The code works fine for me if Adobe Pdf is the active printer but only when I step through the code.

When I try to run it normally I get an error "H:\CreatePDF.ps, Cannot open this file, The file is being used by another process" from Adobe Distiller and then a Run-time error70: Permission denied from Excel on the Kill tempPSFileName line of the code.

I've tried adding a pause at various points thinking that the Adobe may require a bit of time to finish a process but it doesn't seem to make any difference.

I also only had to load the Acrobat Distiller library, the others didn't seem to be required or make any difference.

If I get a chance I'll have another play with it.

Dom
 
Last edited:
Upvote 0
I hope it's okay that I dredge this up as I'm having the exact issue the Domski posted above. Figured since these are almost the exact same thing it wasn't worth it to make a whole new thread (correct me if I'm wrong and I'll fix). I am actually having to make the same macro using the exact same code (Domski you saved my internship, by the way, with this code for excel-to-pdf).

Here is my code:
Code:
Sub Save2PDF()

'The following lines define variables to use for the code
Dim tempPDFFileName As String
Dim tempPSFileName As String
Dim tempPDFRawFileName As String
Dim tempLogFileName As String


'Filepath and name are defined from bookmarks in the document
tempPDFRawFileName = ActiveDocument.Bookmarks("Path111").Range.Text & ActiveDocument.Bookmarks("var111").Range.Text
 
'Names of the temp files are defined
tempPSFileName = tempPDFRawFileName & ".ps"
tempPDFFileName = tempPDFRawFileName & ".pdf"
tempLogFileName = tempPDFRawFileName & ".log"

'Printer is set to Adobe PDF
ActivePrinter = "Adobe PDF"

'Active Document is printed out with following settings
ActiveDocument.PrintOut , Copies:=1, PrintToFile:=True, Collate:=True, OutputFileName:=tempPSFileName

'PdfDistiller is called up
Dim mypdfDist As New PdfDistiller

'Distiller converts to PDF with filename defined above
mypdfDist.FileToPDF tempPSFileName, tempPDFFileName, ""
 
'Cleans up temp files created for conversion and just leaves the pdf
Kill tempPSFileName
Kill tempLogFileName

End Sub


Filepath and name are defined by bookmarks in the document. I get the exact same "Run-time error70: Permission Denied" error when it comes time to convert the .ps file to .pdf.

Any help would be much appreciated.
 
Upvote 0
I admit I haven't looked at this since the question was asked way back so never made any progress on it. If I get a bit of time I'll see if I can come up with anything.

Glad the Excel code helped :-)

Dom
 
Upvote 0

Forum statistics

Threads
1,225,521
Messages
6,185,457
Members
453,292
Latest member
Michandra02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top