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.
 

diddi

Well-known Member
Joined
May 20, 2004
Messages
2,554
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?
 

mohan.pandey87

Board Regular
Joined
Sep 14, 2012
Messages
146
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.
 

aatmik_m24

New Member
Joined
Aug 2, 2013
Messages
6
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
 

Forum statistics

Threads
1,081,690
Messages
5,360,624
Members
400,592
Latest member
badgergurl

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top