View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default print pdf's with changing filenames in a macro

Your using xl97 or earlier? Because that argument is supported in xl2000
and later.

From xl2000 help on Printout
expression.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile,
Collate, PrToFileName)

--
Regards,
Tom Ogilvy



wrote in message
oups.com...
Thanks, When I copied that to my macro, I got "Named argument not
found" compile error and it highlighted "PrToFileName:=" in my code.
Any ideas?


Tom Ogilvy wrote:
have you tried:


ActiveWindow.SelectedSheets.PrintOut Copies:=1, PrintToFile:=True,
PrToFileName:=fn$


--
Regards,
Tom Ogilvy



" wrote:

I have created a macro to isolate certain data based on a variable
loop. I would like to print the data to a pdf file. I was able to get
it to print but it always uses the same filename; "Group" The
following code in a k loop works to make fn$ the filename I desire; I
checked it by sending the fn$ to sequential cells of a sheet.

How can I get the pdf filename to change within the loop?
Thanks for any help.
Charlie




s$ = Str(k)
If k < 10 Then s$ = "0" & Right(s$, 1) Else s$ = Right(s$, 2)
fn$ = "Group" & s$ & ".pdf"

filename:=fn$
ActiveWindow.SelectedSheets.PrintOut Copies:=1