0

I have one issue with one excel VBA, the file it works good collecting data from other open workbook, but, when I use VBScript to open the excel file, when I run the macro in the excel file to collect data from other open workbook, give error "subscript out of range" Can anyone help me?

Do I have to introduce any code in VBS to allow the excel file interact with other open workbooks?

The main reason I use VBS to open the excel file is, because I have a Form and when is open, still alow me to work in other excel files.

Option Explicit
Dim obj, xlBook, Shell
Set obj = CreateObject("Excel.Application")
obj.DisplayAlerts = False
Set xlBook = obj.Workbooks.Open("C:\excel.xlsm", , False)
WScript.Quit
Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
  • You're creating a new instance of Excel, so yeah, it won't "see" workbooks in another instance. – BigBen Mar 17 '22 at 16:37
  • 2
    If you use `GetObject` it will find the open Excel - not sure if it can open a file if you have a modal userform open though. Have you considered opening the form non-modally? – Tim Williams Mar 17 '22 at 16:55

0 Answers0