' Define the postscript and .pdf file names.
Dim PSFileName As String
Dim PDFFileName As String
PSFileName = "C:\myPostScript.ps"
PDFFileName = "C:\myPDF.pdf"
' Print the Excel range to the postscript file
Dim Foglio1 As Worksheet
Set Foglio1 = ActiveSheet
You didn't say you were trying to do this programmatically. My reply would have been a little more detailed, otherwise.
I don't program in VB, so my help won't be much... help.
But I'll try: do you need to check for a succesful print, prior to trying to use Distiller?
Try adding a loop between your printing code and your Distilling code. In that loop, you'll need a "DoEvents()" or whatever the proper VB code is to allow Windows to keep doing whatever else it is doing.
In that loop, you'll need to test that your print file was created, possibly by trying to open it with standard VB File I/O.
When you confirm that the postscript file was succesfully created, then you can move on to your Distiller code block.
I've seen this type of problem when generating files dynamically, and then trying to pass that file onto another process. You have to wait for the system to release all application and OS locks on the file. Thus the loop to test to see if your app can open the file.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.