Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro/VBA code to create PDF files from Word

Status
Not open for further replies.

Jahappz

Technical User
Jun 3, 2002
133
SE
Hi, i have tried to make a macro that saves a .doc as .pdf
and put 2 new buttons in the menues in word.


button nr1 should save a .doc file to "C:\alternative1\"
but i want the macro to ask for the filename for the pdf file.

button nr2 should save a .doc file to "C:\alternative2\"
and ask for the filenamne of the pdf file.


the criterias for the macro is:

1.Specified printer (eg Adobe PDF Writer , dont wanna have it as default printer)
2.location is C:\alternative1 for button nr1 and C:\alternative2 for button nr2 but i want the user to type the filename.
 
Use

ActivePrinter = "(name of Adobe writer)"

to select the printer. You may want to save the name of the original printer first, and restore it afterwards

oldPrinter=ActivePrinter
...
ActivePrinter=oldPrinter

If you need the user to browse for the filename, you'll need to use
application.GetSaveasFilename
to have the user select the filename. Otherwise, just use a textbox to input the filename. Then use the PrintToFile and OutputFilename properties of the Printout method to do the actual output.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top