Link to home
Start Free TrialLog in
Avatar of rvolk
rvolk

asked on

Convert .doc to .pdf... I need the code please!!!

Hello all,
I have this MS Word file that I need to save in .pdf format automatically using VBA.  I can save it manually and it works fine, but I need to write the code for it, so the user doesn't get any dialog boxes prompting for the file name and location.  I would like a full code that can make that work.

Thanks
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Hi rvolk,

Set your default printer to "Acrobat Distiller" and create a macro.

Sub PrintMyFile()
 Dim MyFile as String
 MyFile = "c:\MyDir\MyDoc.doc"
 Documents.Open MyFile
 Documents(MyFile).PrintOut
 Documents.Close
End Sub

or if you don't want to set your default printer then you got to add a line to set the printer for the active document

HAGD:O)Bruintje
Avatar of rvolk
rvolk

ASKER

Thanks for your comments.  If I use this code, I get a dialog box prompting me for the .pdf file name.  I need to supply that name through code.  How do I do that?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello rvolk

this question is open for more then 2 months
time to clean up
if not stated otherwise

my recom will be
-PAQ
-points to bruintje
-this will be finalized by an EE Moderator
-with no further update (19.10.2002)

PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER

HAGD:O)Bruintje
posted by ToolzEE v1.0
Comment from expert accepted as answer

Computer101
E-E Admin