How Return to Calling VBA Code after Application.Run

  • Hello All


    I am stuck. I need to call vba code in a separate Workbook and return to the calling vba procedure an continue execution from the point of the call. I am using Application.Run, but everything stops after the Application.Run ends with End Sub. I am new to VBA and would appreciate some help and a sample snipet of code would be greatly appreciated.


    Thanks

    Raider52

  • Code
    Application.Run (wbTarget.Name & "!Make1RowPDF")
    GoTo UFinn

    After you have called the macro you have

    Code
    GoTo UFinn

    This jumps to the end of the macro and

    Call FinalOne 'Module 4


    I don't know what this other code does

  • Code
    Application.Run (wbTarget.Name & "!Make1RowPDF")
    MsgBox "YOU ARE HERE!!!!!!"
    'GoTo UFinn

    When I put a MsgBox just after the Application.Run call, the message never appears, which tells me the return from !Make1RowPDF terminates the calling procedure (SingleRowPDF). So SingleRowPDF never executed the Call FinalOne 'Module 4 statement. There has to be something wrong within Make1RowPDF, although it does all I want it to do. Make1RowPDF never returns control to SingleRowPDF.

  • Code
    ActiveWorkbook.Save
    ActiveWorkbook.SaveAs FileName:="V:\BankStatementFiles\PDFX_Summary.xlsx", FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Closeapplication.DisplayAlerts = True
    'Stop
    End Sub

    I found the problem... The problem was I was closing the called Workbook with the statement, below. That also terminated the calling procedure. When I commented out the statement below, the return to calling procedure completed the remainder of the processing.


    Thanks to both of you for your help... Stay Safe.

    Code
    ActiveWorkbook.Close

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!