473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Acrobat Distiller 6.0, VBA and MS Word

Like many before me, I am tearing my hair out trying to get Acrobat
6.0 to work with VBA. I am getting close, and the error I am getting
now seems like it should be easy to surmount. So why am I stumped?!
;)

This code is in the middle of a large module in an ADP that takes web
data and ports it to an MS Word form that is dynamically generated
based on the data. Near the end, the Word doc needs to print to PDF
and save both the Word doc and PDF file. I have a working version of
this with Acrobat 4.0 using PDFWriter, but it doesn't work with later
versions of Acrobat and it's past time to upgrade.

Here's a snippet of the code in question (watch the word wrap):

----------------BEGINNING OF CODE----------------
'These three items are string variables, already declared.
'These set the file names instead of making the user type them
'and possibly store them in the wrong place or with the wrong name.
PSfilename = "I:\RPS & REO\BPO's\" & Forms!frmBPOReview!Loan_Num & "_"
& Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower &
".ps"
DOCfilename = "I:\RPS & REO\BPO's\Word\" & Forms!frmBPOReview!Loan_Num
& "_" & Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower
& ".doc"
PDFfilename = "I:\RPS & REO\BPO's\" & Forms!frmBPOReview!Loan_Num &
"_" & Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower &
".pdf"

'Here it calls an external procedure that captures the name
'of the user's default printer so it can be restored afterwards.
'Otherwise their Acrobat driver becomes the default
lpReturnedString = String(100, " ")

'Get the default printer from the win.ini file, application name =
[windows], key name = device
Call GetProfileString("windows", "device", "", lpReturnedString,
Len(lpReturnedString))
'GetDefaultPrinter = lpReturnedString
printer = lpReturnedString

'Print to Postscript/Distiller file
Dim AcroDist As New PdfDistiller6
objWord.ActiveDocument.PrintOut printtofile:=True,
outputfilename:=PSfilename

'Here's where it stops working. I need to convert the file to PDF
'and kill the postscript file
'I'll probably need to add something to kill the log file, too.
'It tries to run the code, but I get an error message
'stating that another process has locked the file.
AcroDist.FileToPDF PSfilename, PDFfilename, ""
Kill PSfilename

'Reset default printer
Call SetDefaultPrinter(printer)

'Close Word, do not save document
objWord.ActiveDocument.SaveAs DOCfilename
objWord.ActiveDocument.Close
If AppNotRunning = True Then
objWord.Quit
End If
----------------END OF CODE----------------

As the code notes state above, Distiller tries to covert the PS file
to PDF, but it can't continue because a process has it locked, and I
don't know why or which process. I have tried saving and closing Word
before making the PDF conversion, but that didn't help.

Any help would be appreciated.
Nicole
Nov 13 '05 #1
1 6523
Resolved. I kept moving it around until I found a spot -- AFTER I
close Word AND release the object. (Even though closing Word should
have been enough.)

-------------START OF SAMPLE CODE--------------

'Previously declared string variables
PSFilename = "I:\RPS & REO\BPO's\" & Forms!frmBPOReview!Loan_Num & "_"
& Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower &
".ps"
DOCfilename = "I:\RPS & REO\BPO's\Word\" & Forms!frmBPOReview!Loan_Num
& "_" & Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower
& ".doc"
PDFFilename = "I:\RPS & REO\BPO's\" & Forms!frmBPOReview!Loan_Num &
"_" & Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower &
".pdf"
LogFilename = "I:\RPS & REO\BPO's\" & Forms!frmBPOReview!Loan_Num &
"_" & Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower &
".log"

{snip -- other unrelated stuff here}

'Print to postscript/Distiller file
objWord.ActivePrinter = "Adobe PDF"
objWord.ActiveDocument.PrintOut printtofile:=True,
outputfilename:=PSFilename

{snip -- other unrelated stuff here}

'Close Word, do not save document
objWord.ActiveDocument.SaveAs DOCfilename
objWord.ActiveDocument.Close
If AppNotRunning = True Then
objWord.Quit
End If

{snip -- other unrelated stuff here}

Set objWord = Nothing

'Covert PS file to PDF and kill extra files that were generated
Dim AcroDist As New PdfDistiller6
AcroDist.FileToPDF PSFilename, PDFFilename, ""
Kill PSFilename
Kill LogFilename

PSFilename = ""
PDFFilename = ""
DOCfilename = ""
LogFilename = ""

-------------END OF SAMPLE CODE--------------
ni*****@namg.com (Nicole) wrote in message news:<7f*************************@posting.google.c om>...
Like many before me, I am tearing my hair out trying to get Acrobat
6.0 to work with VBA. I am getting close, and the error I am getting
now seems like it should be easy to surmount. So why am I stumped?!
;)

This code is in the middle of a large module in an ADP that takes web
data and ports it to an MS Word form that is dynamically generated
based on the data. Near the end, the Word doc needs to print to PDF
and save both the Word doc and PDF file. I have a working version of
this with Acrobat 4.0 using PDFWriter, but it doesn't work with later
versions of Acrobat and it's past time to upgrade.

Here's a snippet of the code in question (watch the word wrap):

----------------BEGINNING OF CODE----------------
'These three items are string variables, already declared.
'These set the file names instead of making the user type them
'and possibly store them in the wrong place or with the wrong name.
PSfilename = "I:\RPS & REO\BPO's\" & Forms!frmBPOReview!Loan_Num & "_"
& Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower &
".ps"
DOCfilename = "I:\RPS & REO\BPO's\Word\" & Forms!frmBPOReview!Loan_Num
& "_" & Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower
& ".doc"
PDFfilename = "I:\RPS & REO\BPO's\" & Forms!frmBPOReview!Loan_Num &
"_" & Forms!frmBPOReview!Address & "_" & Forms!frmBPOReview!Borrower &
".pdf"

'Here it calls an external procedure that captures the name
'of the user's default printer so it can be restored afterwards.
'Otherwise their Acrobat driver becomes the default
lpReturnedString = String(100, " ")

'Get the default printer from the win.ini file, application name =
[windows], key name = device
Call GetProfileString("windows", "device", "", lpReturnedString,
Len(lpReturnedString))
'GetDefaultPrinter = lpReturnedString
printer = lpReturnedString

'Print to Postscript/Distiller file
Dim AcroDist As New PdfDistiller6
objWord.ActiveDocument.PrintOut printtofile:=True,
outputfilename:=PSfilename

'Here's where it stops working. I need to convert the file to PDF
'and kill the postscript file
'I'll probably need to add something to kill the log file, too.
'It tries to run the code, but I get an error message
'stating that another process has locked the file.
AcroDist.FileToPDF PSfilename, PDFfilename, ""
Kill PSfilename

'Reset default printer
Call SetDefaultPrinter(printer)

'Close Word, do not save document
objWord.ActiveDocument.SaveAs DOCfilename
objWord.ActiveDocument.Close
If AppNotRunning = True Then
objWord.Quit
End If
----------------END OF CODE----------------

As the code notes state above, Distiller tries to covert the PS file
to PDF, but it can't continue because a process has it locked, and I
don't know why or which process. I have tried saving and closing Word
before making the PDF conversion, but that didn't help.

Any help would be appreciated.
Nicole

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andrew | last post by:
My VB Application opens an Access Report and has an option to generate the report in PDF once the report is closed. This is accomplished by: - Switching over to the Acrobat Printer (i.e....
5
by: Filips Benoit | last post by:
Dear All, How to check if Acrobat Distiller is running and how to start it before output? Filip
2
by: Markus Ernst | last post by:
Hi I generate Unicode PDFs with TCPDF, a Unicode compatible extension of FPDF. While in newer Acrobat Reader versions the PDFs are displayed well, Acrobat Reader 4 (on both Mac OS 9.2 and...
13
by: kbperry | last post by:
Hi all, Background: I need some help. I am trying to streamline a process for one of our technical writers. He is using Perforce (version control system), and is constantly changing his word...
7
by: Quasimenudo CSS | last post by:
why does anyone use acrobat distiller, or whatever adobe calls that currently? iv'e used the pdf pseudo printer drivers when somene requested pdf format. and the result looked rather close to the...
3
by: mzmishra | last post by:
Hi, I have one application in c# .net 1.1. I like to convert word to pdf using Adobe Distiller . Can any body help me get some code samples in C# for the same?
2
by: ncsthbell | last post by:
I am just not sure the most efficient way to handle this. I have never used Adobe other than to open a document and read it! I have had Adobe Pro 8 installed on my machine to accomodate this...
1
by: Raymond Chiu | last post by:
Dear all, I have vb.net program which export excel to pdf format. I am using acrobat distiller but find the problem in the below statement. dim ddt as new ACRODISTXLib.PdfDistiller...
1
by: ncsthbell | last post by:
I am looking for any help with calling 'Acrobat Distiller' using an API from within Access. I have searched on the Internet and it is so very confusing!! I have the product installed but am looking...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.