SaveAsPDF Macro - Syntax Error

aatmik_m24

New Member
Joined
Aug 2, 2013
Messages
6
My Code for Saving an Invoice Template to PDF at a specified location is -

Sub SavePDF()
' pdf Macro
Application.ScreenUpdating = False
Sheets("Invoice").Select
Range("A1:A52").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
"G:\Electronyx Bazaar\Invoice\" & Range("A9").Value & " Order No# " & Range("F9").Value & " Invoice No #" & Range("F3").Value & " " & Range("F13").Value & " " & "AWB - " & Range("F11").Value, Quality:=xlQualityStandard, IncludeDocProperties:=
False, IgnorePrintAreas:=False, OpenAfterPublish:=False
Sheets("Invoice").Select
Range("B1").Select

Application.ScreenUpdating = False
End Sub


THIS CODE GIVES ME SYNTAX ERROR.
I DO NOT UNDERSTAND WHERE IS THE ISSUE.

Please help its urgent, this is my invoicing requirement for daily purpose.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
can I suggest you define the file name before the export. it might simplify everything a bit.
eg
Code:
Dim MyExport as string
MyExport = "G:\Electronyx Bazaar\Invoice\" & Range("A9").Value & " Order No# " & Range("F9").Value & " Invoice No #" & Range("F3").Value & " " & Range("F13").Value & " " & "AWB - " & Range("F11").Value

which line is erroring?
 
Upvote 0
As i have tested the code it is working fine but in your case i need to check your path and in your example it is comming from some ranges so it would be helpfull to have these value to make proper path. please attache your file with some dummy data.
 
Upvote 0
can I suggest you define the file name before the export. it might simplify everything a bit.
eg
Code:
Dim MyExport as string
MyExport = "G:\Electronyx Bazaar\Invoice\" & Range("A9").Value & " Order No# " & Range("F9").Value & " Invoice No #" & Range("F3").Value & " " & Range("F13").Value & " " & "AWB - " & Range("F11").Value

which line is erroring?

Please provide me the Full Code.

The code you have provided , I do not understand where to place it.
It says - Expected Function or Variable when I alter it like this -
Sub SavePDF()' pdf Macro
Application.ScreenUpdating = False
Sheets("Invoice").Select
Range("A1:A52").Select
Dim MyExport As String
MyExport = "G:\Electronyx Bazaar\Invoice\" & Range("A9").Value & " Order No# " & Range("F9").Value & " Invoice No #" & Range("F3").Value & " " & Range("F13").Value & " " & "AWB - " & Range("F11").Value
Sheets("Invoice").Select
Range("B1").Select

Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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