Closed Thread
Results 1 to 12 of 12

Compile Error: Expected Expression

  1. #1
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Compile Error: Expected Expression

    I am simply trying to export the active sheet as a pdf with the below code, however, I keep getting "Compile error: expected expression" with the ':=' highlight after Filename. Any idea what is causing this error? I see this same line in other users' code frequently so I'm not sure what I am missing

    Please Login or Register  to view this content.



    Thanks!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compile Error: Expected Expression

    The line is extended and then broken - try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compile Error: Expected Expression

    It seems is missing "_", put the complete statement in only one ligne.
    - Battle without fear gives no glory - Just try

  4. #4
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Compile Error: Expected Expression

    Thanks to both of you! Now it is allowing that to work!

    Best!

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compile Error: Expected Expression

    You're welcome

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Compile Error: Expected Expression

    You're welcome and thanks for the rep!

  7. #7
    Registered User
    Join Date
    09-09-2022
    Location
    Mackay, QLD
    MS-Off Ver
    2022
    Posts
    5

    Re: Compile Error: Expected Expression

    Hi I have been having the same issue, although I have just tried changing it to the same format you suggested and it is still not working. Any suggestions?

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compile Error: Expected Expression

    Please send a copy of your code

  9. #9
    Registered User
    Join Date
    09-09-2022
    Location
    Mackay, QLD
    MS-Off Ver
    2022
    Posts
    5

    Re: Compile Error: Expected Expression

    I don't know what I done other then re-typed the whole thing exactly as it was and now it is working again. Here is what I done for a reference. Thanks anyway!

    Sub saveaspdf()

    Dim invno As Long
    Dim custname As String
    Dim amt As Currency
    Dim dt_issue As Date
    Dim term As Byte
    Dim path As String
    Dim fname As String
    Dim nextrec As Range

    invno = Range("C3")
    custname = Range("B10")
    amt = Range("G38")
    dt_issue = Range("C5")
    term = Range("C6")
    path = "/Users/georgiasharp/Library/Mobile Documents/com~apple~CloudDocs/2. GEE'S ISAC/BUSINESS/2022:2023/INVOICES/1. TO PRINT/"
    fname = invno & " - " & custname

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ignoreprintareas:=False, FileName:=path & fname

    Set nextrec = Sheet4.Range("A1048576").End(xlUp).Offset(1, 0)

    Sheet4.Hyperlinks.Add anchor:=nextrec.Offset(0, 6), Address:=path & fname & ".pdf"

    End Sub

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compile Error: Expected Expression

    Where was the issue ?

  11. #11
    Registered User
    Join Date
    09-09-2022
    Location
    Mackay, QLD
    MS-Off Ver
    2022
    Posts
    5

    Re: Compile Error: Expected Expression

    It's doing it again.

    ActiveSheets.ExportAsFixedFormat:=xlTypePDF, ignoreprintareas:=False, FileName:=path & name

    what im doing is right before I run the macro I change the print areas so it only displays the invoice and then I run the macro and it is saying printing area. I tried undoing it and not reseting the print area and it is still saying the same thing.

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,900

    Re: Compile Error: Expected Expression

    Hi.

    It's a forum rule that you start your own thread, rather than "piggy-backing" on someone else's thread. This helps prevent massive confusion arising - which will happen if it is not clear which question is being answered. So please start your own thread and explain your own problem (make sure that, right from the start, you use a meaningful title (NOT things like "help needed" or "urgent problem"... think of the Google search terms that you would use to find the solution).

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 pictures. So, prepare a SMALL sample sheet (10-20 rows, not thousands!!!). Make sure there is enough data to demonstrate your need. Make sure your desired results are shown, mock them up manually if necessary. Remember to remove ALL confidential information first!!!


    The yellow banner about sample worksheets, at the top of the screen tells you how to post a sheet here on the Forum.

    Thread CLOSED.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compile Error: Expected expression
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2016, 02:33 PM
  2. [SOLVED] UDF gives compile error: expected:expression
    By adh2 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2015, 05:37 PM
  3. Compiile error: Expected: expression
    By soldgold in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-01-2015, 04:46 AM
  4. VBA error question (Expected expression) Application.Worksheetfunction
    By Gijsbenjezelf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2014, 12:40 PM
  5. [SOLVED] Compile Error: Expected: expression
    By Wheelie686 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2013, 08:51 AM
  6. [SOLVED] Compile Error: Expected Expression, Syntax Error
    By gjohn282 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 11:28 PM
  7. [SOLVED] if isna vlookup expected expression error
    By harishankarin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2010, 04:16 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1