Macro - Feeding path and file name to PDF maker

B

Bill

Hi,

I am using a macro to create a report and the last step is to print a
particular worksheet using a PDF maker. I have figured out how to specify
the printer as being the PDF maker, but I also want to be able to
automatically enter the file name and path, which I will build within the
macro depending upon some user inputs. I've built the text strings as I
need, I just need to be able to "feed" them to the PDF maker rather than
have the dialog box come up and ask the user for that information.

Any help?

Bill
 
D

Darcy

Hi Bill,

I stumbled in here today to find the answer to a similar question. I also am
creating a macro to automatically print Excel worksheets to pdf. The
following is what I have so far in part of my macro:

Application.ActivePrinter = "Adobe PDF on Ne00:"
If XStr = "X" Then
Application.Run AppStr
Sheets("SUMMARY").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True,
PrToFileName:="C:\Documents and Settings\marusichd\Desktop\Email Worksheets\"
& CoName & ".pdf"
Sheets("FLEET").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True,
PrToFileName:="C:\Documents and Settings\marusichd\Desktop\Email Worksheets\"
& CoName & "2.pdf"
Sheets("SELECT TO PRINT").Select

End If

It seems to work ok up to a point. The pdf file is created in the selected
location, however the file is empty (0 KB) or when opened states it is
corrupt. !?! This is what I was looking for help on. Did you get anything to
work out?

Thanx,
Darcy :eek:)
 
Top