PDA

View Full Version : PDF Creator Code - Making Filename match a cell



jonrouston
2012-05-25, 05:31 PM
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


'/// Change the output file name here! ///
sPDFName = "example.pdf"
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator

Which I've changed to:



'/// 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



'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

tommyt61
2012-05-28, 07:06 PM
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.

jonrouston
2012-05-29, 10:48 AM
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!