Macro to save worksheet as .pdf has stopped working, unsure of cause

cravincullen

New Member
Joined
Jun 8, 2015
Messages
1
Hello,

I've been using a macro to save unique invoices as pdf files to distribute to vendors. My macro used to work, but now does not. After attempting to use macro by hitting the button I've created, I receive the error

'Microsoft Visual Basic

400'

I'm unsure of how I've fouled what useful code was there, but have attached screen shots that will hopefully be helpful. As you can see, I'm using a Mac, and Excel Mac 2011 14.5.1... unsure if that is of any consequence. The file path should be correct, I have not moved that file or edited permissions or anything of the sort.

Screen%20Shot%202015-06-08%20at%206.56.10%20PM.png



Screen%20Shot%202015-06-08%20at%206.56.29%20PM.png



Screen%20Shot%202015-06-08%20at%206.56.42%20PM.png


Macro in text for reference:
Sub SavePDF()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="Macintosh HD:Users:Cullenation:Desktop:CravinVapes - SHAWNS:" & _
ActiveSheet.Range("A8").Value & ActiveSheet.Range("E4").Value & ".pdf", _
OpenAfterPublish:=True
End Sub

While I'm at it, a pop-up with an option to print to a local printer would be divine.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Also, might want to break up the problem to make it easier to troubleshoot, this way you can step through the program and see in a watch window what the text of the filename is just before it executes ExportAsFixedFormat

Code:
[I]Sub SavePDF()[INDENT]Dim fName as String

fName = "Macintosh HD:Users:Cullenation:Desktop:CravinVapes - SHAWNS:" & _[/INDENT]
[INDENT=2]ActiveSheet.Range("A8").Value & ActiveSheet.Range("E4").Value & ".pdf"[/INDENT]
[INDENT][I]
ActiveSheet.ExportAsFixedFormat _
[/I][/INDENT]
[INDENT=2][I][I]Type:=xlTypePDF, _
[/I][/I][/INDENT]
[INDENT=2][I][I]Filename:=fName, _[/I][/I][/INDENT]
[INDENT=2][I][I][I][I]OpenAfterPublish:=True
[/I][/I][/I][/I][/INDENT]
[/I][I][I][I][I][I][I]End Sub[/I][/I][/I][/I][/I][/I]
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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