PDF Creator Code - Making Filename match a cell

jonrouston

New member
Joined
May 25, 2012
Messages
2
Reaction score
0
Points
0
Hi

I'm trying to automate the printing of PDF's and after going round in circles with acrobat solutions, I the PDF creator code here and it worked great until I changed a variable and it's now getting stuck in a loop

Originally the code was something like
Code:
'/// Change the output file name here! /// 
sPDFName = "example.pdf" 
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator
Which I've changed to:

Code:
'/// Change the output file name here! /// 
sPDFName = Sheets("Invoicer").Range("D5") 
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator & "Invoices/"
Which works, the pdf is printed in the right directory and with the right name, however it now gets stuck here

Code:
'Wait until the file shows up before closing PDF Creator 
Do 
DoEvents Loop Until Dir(sPDFPath & sPDFName) = sPDFName

And it's a little beyond my skills as to why (it's probably very simple).
If anyone could help I'd really appreciate it.

Thanks

Jon
 
Last edited:

tommyt61

New member
Joined
Mar 26, 2011
Messages
153
Reaction score
0
Points
0
Jon,

See if this is what you might be trying to do. For this to work correctly make you a folder C:\Invoices
When you run the macro it will save the pdf into C:\Invoices

This should give you a good idea of how the code works so you can adjust it to fit your situation.
 

Attachments

  • Invoice_EM.xls
    45 KB · Views: 121

jonrouston

New member
Joined
May 25, 2012
Messages
2
Reaction score
0
Points
0
Jon,See if this is what you might be trying to do. For this to work correctly make you a folder C:\InvoicesWhen you run the macro it will save the pdf into C:\InvoicesThis should give you a good idea of how the code works so you can adjust it to fit your situation.
Works perfectly thank you so much!
 
Top