I'm trying to use this VBScript to open a file and run a macro. Ideally I'd open it from my personal workbook, but happy to run from anywhere as a compromise.
Option Explicit
On Error Resume Next
RunExcelMacro
Sub RunExcelMacro()
Dim xlApp
Dim xlBook
If CheckAppOpen("excel.application") Then
'MsgBox "App Loaded"
Set xlApp = GetObject(, "Excel.Application")
Else
' MsgBox "App Not Loaded"
Set xlApp = CreateObject(,"Excel.Application")
End If
xlApp.visible = True
set xlBook = xlApp.Workbooks.Open ("C:\Users\....\PERSONAL.xlsb", 0, True)
xlApp.Run "Module1.My Macro"
xlApp.Quit()
xlBook = Nothing
xlApp = Nothing
End Sub
The script does not open any Excel file, independent of if it being on a server or in my C drive.
There's been a fair number of posts on this. I did some research.
I tried:
Set xlApp = GetObject("Excel.Application")
Set xlApp = CreateObject("Excel.Application")
as well as
Dim Filename as string
Filename = "C:/....."
set xlBook = xlApp.Workbooks.Open (Filename)
I've tried opening .xls, .xlsm, .xlsb all to no avail.
I am not getting any error messages. The cmd console opens and then closes with this
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
On Error Resume Nextand run this from a cmd window (cscript.exe your.vbs) to see the error messages.Set xlApp = CreateObject("Excel.Application")