Results 1 to 3 of 3

Thread: Excel VBA

  1. #1
    New Lounger
    Join Date
    Feb 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel VBA

    Hi all,

    having problem with VBA code, come up with Compile error: Expected Expression


    'SaveInvoice

    Dim fName As String
    With Worksheets("Address")
    fName = .Range("N12").Value & .Range("O12").Value
    End With
    Sheets("Address").ExportAsFixedFormat Type:=xlTypePDF, FileName:="C:\User\Stephen\SMS\Invoice\" & fName_
    Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=True, OpenAfterPublish:=false

    the first ":=" after "Quality" is highlighted with the error msgbox

    App. is Excel 2010

    be grateful if someone can guide me. Thanks

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,203
    Thanks
    49
    Thanked 989 Times in 919 Posts
    I would create a variable called FullfName and set it to the fully qualified path and filename, then use only that variable in FileName. Don't forget the spave before the underscore / line break.

    Sheets("Address").ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullfName _
    Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=True, OpenAfterPublish:=false

    cheers, Paul

  3. #3
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Redditch, Worcestershire, England
    Posts
    233
    Thanks
    0
    Thanked 22 Times in 21 Posts
    Quote Originally Posted by R3dcoat View Post
    Hi all,

    having problem with VBA code, come up with Compile error: Expected Expression


    'SaveInvoice

    Dim fName As String
    With Worksheets("Address")
    fName = .Range("N12").Value & .Range("O12").Value
    End With
    Sheets("Address").ExportAsFixedFormat Type:=xlTypePDF, FileName:="C:\User\Stephen\SMS\Invoice\" & fName_
    Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=True, OpenAfterPublish:=false

    the first ":=" after "Quality" is highlighted with the error msgbox

    App. is Excel 2010

    be grateful if someone can guide me. Thanks
    Unless I'm much mistaken, you're missing a comma either after fName or before Quality - all the assignment expressions need to be separated by commas.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •