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.









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.
 

bEErad

New Member
Joined
Jun 9, 2015
Messages
2
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]
 

Forum statistics

Threads
1,082,139
Messages
5,363,362
Members
400,730
Latest member
cookie123

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top