My objective is to open an Excel ActiveForm using .VBS Script
As soon as Excel Activeform is opened, Following VBA code will run.
NOTE: All Macros are enabled in Excel Trust Center Settings
Code: Select all
Private Sub workbook_open()
Workbooks.Open ("C:\Program Files\ibm\cognos\tm1_64\bin\tm1p.xla")
Application.Run "N_CONNECT", "Test Server", "admin", ""
Application.Run "TM1RECALC1"
End Sub
Code: Select all
RunMacro
Sub RunMacro()
Dim xl
Dim xlBook
path = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
Set xl = CreateObject("Excel.application")
Set xlBook = xl.Workbooks.Open("d:\TM1 Assets\ExcelActiveForm.xlsm", 0, True)
xl.Application.Visible = False
xl.DisplayAlerts = true
xl.Quit
Set xlBook = Nothing
Set xl = Nothing
End Sub
Problem Statement:
As soon as I run the .VBS Script, it gives me an error: Cannot run macro n_connect. Howevere, I would like to let you know that, when I open (Double click) ExcelActiveForm.xlsm it doesnt throw such errors. Everything runs flawless and ActiveForm is recalculated.
I need your suggestions to get rid of that error. Any inputs for this issue will be highly appreciated.
Thanks a lot!
Cipher.