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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,849
Office Version
  1. 365
Platform
  1. Windows
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

gokuthemighty

New Member
Joined
Sep 1, 2014
Messages
2
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,191,122
Messages
5,984,773
Members
439,910
Latest member
Flyingjoblo

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
Top