Working on a Windows 7 Enterprise x64 host with 64-bit Microsoft Office Professional Plus 2016 installed.
I'd like to create Visual Basic script vbscript (a file on my Windows desktop) that launches Microsoft Excel, opens the macro-enabled Excel workbook file "Workbook.xlsm", and selects/activates the worksheet "XYZ" within that workbook. So, I woite the following VB script:
' File: test.vbs
' Opens Excel workbook "Workbook.xlsm" to worksheet "XYZ"
Set objXl = CreateObject("Excel.Application")
Set ObjWb = objXl.Workbooks.Open("C:\Path\To\Workbook.xlsm")
objXl.Goto ObjWb.Sheets("XYZ").Range("A1")
objXl.Application.Visible = True
This script successfully launches excel, opens the specified workbook, and selects the specified worksheet.
However, all worksheet cells containing a formula that invokes one or more functions defined within an add-in module are all broken; these cells all contain the error value #NAME?.
If I manually close and reopen the workbook (not using the script), the worksheet cells containing a formula that invokes one or more functions defined within an add-in module all work correctly.
So I'm wondering how to modify my Visual Basic script so that after it launches Excel, and opens the workbook, and selects the desired worksheet, the workbook's worksheet cells can successfully invoke functions defined in add-in modules.
ObjWb.Sheets
instead ofObjWbSheets
? – Gurmanjot Singh