I have a macro that interfaces with SAP. The SAP portion is for it to run a report and open it in Excel. Excel takes over and activates the workbook, then saves it in a location and converts the file type from .MHTML to .xlsx.

When I step through the macro using F8 along the way, I have no issues. The macro works as expected. When I run the macro, however, it hits an error because my personal workbook somehow gets opened as read-only and I have to negotiate the message box saying that my personal workbook is locked for editing. Again, this is ONLY when I run the macro and does not appear when I step through it.

Here is the code:

Sub SAPScript()Application.DisplayAlerts = False
If Not IsObject(SAPGuiApp) Then
   Set SapGuiAuto = GetObject("SAPGUI")
   Set SAPGuiApp = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = SAPGuiApp.Children(0)
End If
If Not IsObject(session) Then
   Set session = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session, "on"
   WScript.ConnectObject Application, "on"
End If
session.findById("wnd[0]").resizeWorkingPane 167, 36, False
session.findById("wnd[0]/tbar[0]/okcd").text = "/NZSD_INFOREQ_RPT"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtSO_DATES-LOW").text = Date - 30
session.findById("wnd[0]/usr/ctxtSO_DATES-HIGH").text = Date
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]").resizeWorkingPane 167, 36, False
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "I:\Bryan Voskuil\Product Operations\Product Service Representatives\Workflow Reporting\"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "export.MHTML"
Application.Wait (Now + TimeValue("00:00:05"))
    ActiveWorkbook.SaveAs Filename:= _
        "I:\Product Service Representatives\Workflow Reporting\Power BI Data\Rolling_30_Workflow_PowerBI.xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Application.DisplayAlerts = True
End Sub
Here is where the problem occurs:

session.findById("wnd[1]/usr/ctxtDY_PATH").text = "I:\Bryan Voskuil\Product Operations\Product Service Representatives\Workflow Reporting\"session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "export.MHTML"
Application.Wait (Now + TimeValue("00:00:05"))
The blue piece of code is where SAP goes ahead and saves the file which opens automatically. When the file opens at that point, I get the dialog box saying the the personal workbook is locked for editing. Since that message box is open, I cannot perform the bit of code that is highlighted in red, which is technically where the macro fails.

Any insight as to why that is and how to get around it?

I have a number of macros in my personal workbook that need to be preserved and on hand for other tasks, for whatever that is worth.

Thank you for your assistance.