how to save selected cell to pdf with certain file name, in specific folder.

KurtyK

New Member
Joined
Jul 8, 2014
Messages
8
Hi guys,

I am trying to figure out this macro and can't seem to make it save correctly. I am trying to save this selection to pdf and then make it save the filename as "O'shirts Estimate (value of cell 4f and the current date).
It only saves the file as this

O'shirts Estimate & WST Screen Print Auto Invoice.pdf

It should be: O'shirts Estimate Julie 7/8/14.pdf


This is what I have so far:

Sub SavePDF()
'
' SavePDF Macro
'


'
ActiveWindow.SmallScroll Down:=-24
Range("A1:F26").Select
ChDir "Macintosh HD:Users:KurtKunzler:Desktop:Desktop:O'shirts:"
Range("A1:F26").Select
ActiveWorkbook.SaveAs Filename:= _
"Macintosh HD:Users:KurtKunzler:Desktop:Desktop:O'shirts:Estimates:O'shirts Estimate & WST.Cells(4, F).Text & Format(Now, m-dd-yy).pdf" _
, FileFormat:=xlPDF, PublishOption:=xlSelection
End Sub


Can anyone help me?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I don't have a Mac, so I can't be sure, but in windows, if it is not a variable, you need to put double quotes around the F in the cell address. They are also needed around the template in the format statement.
Without an Option Explicit statement, F would be taken as a variable and being undeclared have no value. I get an error when I try to run that part of the code (Run-time error 1004: Application-defined or object-defined error).
Rich (BB code):
"Macintosh HD:Users:KurtKunzler:Desktop:Desktop:O'shirts:Estimates:O'shirts Estimate & WST.Cells(4, "F").Text & Format(Now, "m-dd-yy").pdf" _
, FileFormat:=xlPDF, PublishOption:=xlSelection

Try putting
Rich (BB code):
Debug.Print WST.Cells(4, F).Address
in the code and see what shows in the immediate window.

The 'Option Explicit' statement is very useful. You can include it automatically in the VBE by selecting Tools | Options | Editor | Require Variable Declaration
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,638
Members
449,461
Latest member
kokoanutt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top