Results 1 to 7 of 7

Thread: Run-Time error 424 - Export to PDF Sheets - Array
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jun 2019
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Run-Time error 424 - Export to PDF Sheets - Array

    Hi all

    I am very new to VB and its mostly thanks to forums like this and a bit of internet searching.

    I have a Run-time error 424 - Object required issue

    Let me explain what I'm doing:
    I have a commandButton that actions SaveAs PDF
    The one button has to only export 2 specific sheets to PDF
    The msgbox pops up and is giving me the correct filename (which I have selected)
    But when I say save after that it ends with the runtime error - I am presuming its the sheets (array argument

    Please can someone look at this for me and tell me what I am doing wrong:

    Private Sub CommandButton2_Click()
    answer = msgbox("Do you want to export the quotation to PDF?", vbYesNo + vbQuestion, "Export Quotation to PDF")
    If answer = vbYes Then
    filesSaveName = Application.GetSaveAsFilename(Sheet49.Range("N13"), fileFilter:="PDF(*.pdf),*.pdf")
    If fileSaveName <> True Then
    Sheets(Array("AutoRate Quote Form", "Excess Sheet")).Select
    ActiveSheets.ExportAsFixedFormat Type:=xlTypePDF, filename:=fileSaveName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    End If
    End If
    End Sub

    Thanks in advance

  2. #2
    New Member
    Join Date
    Jun 2019
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run-Time error 424 - Export to PDF Sheets - Array

    Fixed my spelling error on FileSaveName, but still getting a 424

  3. #3
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,043
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Run-Time error 424 - Export to PDF Sheets - Array

    There's no array in that code.

    The only thing I can see that might cause the error you describe is if you don't have a worksheet with the codename Sheet49 in the active worksheet.
    If posting code please use code tags.

  4. #4
    New Member
    Join Date
    Jun 2019
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run-Time error 424 - Export to PDF Sheets - Array

    Sheet 49 reference is working fine. That's the filename sheet (the active one).

    The error is this part i think:

    Sheets(Array("AutoRate Quote Form", "Excess Sheet")).Select

    Since this is the only difference (besides activesheets & activeworkbook)

  5. #5
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,043
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Run-Time error 424 - Export to PDF Sheets - Array

    Is that the line causing the error?

    If it is do you have sheets named 'AutoRate Quote Form' and 'Excess Sheet' in the active workbook?

    If it isn't which line is causing the error and what's the error message?
    If posting code please use code tags.

  6. #6
    New Member
    Join Date
    Jun 2019
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run-Time error 424 - Export to PDF Sheets - Array

    Yes I have those sheets Sheet49 and Sheet26

    It's not highlighting the error line.

  7. #7
    New Member
    Join Date
    Jun 2019
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run-Time error 424 - Export to PDF Sheets - Array

    I got it to work:

    PHP Code:
    Private Sub CommandButton2_Click()answer msgbox("Do you want to export the quotation to PDF?"vbYesNo vbQuestion"Export Quotation to PDF")If answer vbYes ThenfileSaveName Application.GetSaveAsFilename(Sheet49.Range("N13"), fileFilter:="PDF(*.pdf),*.pdf")If fileSaveName <> False ThenSheets(Array("AutoRate Quote Form""Excess Sheet")).SelectActiveSheet.ExportAsFixedFormat Type:=xlTypePDFfilename:=fileSaveNameQuality:=xlQualityStandardIncludeDocProperties:=TrueIgnorePrintAreas:=FalseOpenAfterPublish:=True    End IfEnd IfEnd Sub 
    Thanks for the help Norie

    A

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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