locked
Excel will not recognize open Workbooks when ran with VBScript RRS feed

  • Question

  • I am trying to have Task Scheduler run a macro that pulls a report off of SAP. So, I have a vbscript to open my excel file and my macro runs on opening. The GUI Scripting portion of the vba code exports SAP data into an new excel spreadsheet then my code transfers that data to my already open workbook. The code runs perfect if I open the excel file manually but when I try to open/run the excel file with vbscript, excel is unable to recognize the new workbooks that are generated from SAP so I get a "subscript out of range error." The SAP generated workbooks will show up in my Project Window when I run it manually but will not when using vbscript.

    Thank you in advance for the help!

    VBSCRIPT CODE

    ExcelFilePath = "MyFilePath"

    Set ExcelApp = CreateObject("Excel.Application")

    ExcelApp.Visible = True  'or "False"

    Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)

    MsgBox "Vibration Report successfully ran at " & TimeValue(Now), vbInformation


    • Edited by Melisa C Thursday, September 5, 2019 3:30 PM
    Thursday, September 5, 2019 3:30 PM