justanotheruser
Board Regular
- Joined
- Aug 14, 2010
- Messages
- 96
Hi all,
I've been reading around on the website, and all the threads that I have found have been very useful, but it seems that no-one has asked how to create a macro that allows a custom PDF file name from a cell and a customer folder name, from another cell.
I'm running Excel 2010 on Windows 7 and have two options for my printing.
a) Use CutePDF writer as a printer to save as a PDF (although from what I've read, its not easy to insert a file name there).
b) Use the in-built save as PDF now in Office 2007/Office 2010 to try this.
From what I can tell (I'm new to VBA, so I might be wrong) it maybe easier to use the latter option for my problem.
Basically, the reason that I need a custom folder name is because the sheet I am saving to PDF needs to be put in a folder according to the month it was created in. The code I have tried so far is:
Cell B7 is an alpha-numeric code such as C0156-6302K, which seems to work fine.
Cell H17 contains the formula =NOW() which has been custom formatted to "mmm yy" - so that currently it shows "Aug 10". I have two problems:
Thank you in advance for your help!
I've been reading around on the website, and all the threads that I have found have been very useful, but it seems that no-one has asked how to create a macro that allows a custom PDF file name from a cell and a customer folder name, from another cell.
I'm running Excel 2010 on Windows 7 and have two options for my printing.
a) Use CutePDF writer as a printer to save as a PDF (although from what I've read, its not easy to insert a file name there).
b) Use the in-built save as PDF now in Office 2007/Office 2010 to try this.
From what I can tell (I'm new to VBA, so I might be wrong) it maybe easier to use the latter option for my problem.
Basically, the reason that I need a custom folder name is because the sheet I am saving to PDF needs to be put in a folder according to the month it was created in. The code I have tried so far is:
Code:
Sub Make_PDF()
' Create and save .pdf
Dim pdfName As String
pdfName = Range("B7").Text
FolderName = Range("H17").Text
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="D:\Invoices\" + FolderName + pdfName + ".pdf" _
, Quality:=xlQualityMedium, IncludeDocProperties:=False, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
Cell H17 contains the formula =NOW() which has been custom formatted to "mmm yy" - so that currently it shows "Aug 10". I have two problems:
- When I save it currently, the file saves in D:\Invoices\ under the file name: "Aug 10C0156-6302K.pdf" as an example.
- I would like it to be saved under D:\Invoices\Aug 10\ under the name "C0156-6302K.pdf".
- Also, if possible I would like the user to be able to see a confirmation screen (the prompt window) so that they can confirm the file save location.
Thank you in advance for your help!