Newbe please help convert to Pdf using current directory.

gokuthemighty

New Member
Joined
Sep 1, 2014
Messages
2
Hello I am new to excel and using windows & 64 bit and Excel 2013
For work we have to save in a file based on the month. The same lines of code work in a saveas macro but give me errors in every way I try them in a covert to pdf. Can anyone tell me what is wrong with this code? Thanks.


[Sub SaveAsPDF()


Dim str As String
str = ThisWorkbook.Path


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="str & "\" & "SW Patrol " & Format(DateAdd("d", -1, Date), "m-dd-YY").pdf", _
OpenAfterPublish:=True

End Sub]
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You have you quotes a little mixed up.

Code:
 ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=str & "\" & "SW Patrol " & Format(DateAdd("d", -1, Date), "m-dd-YY") & ".pdf", OpenAfterPublish:=True
 
Upvote 0
Thank you that fixed it. silly easy of course and now I know. I was copy and pasting from one code to another. The one I was copying pdf from had filename in quotes.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,331
Members
449,077
Latest member
jmsotelo

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