Page 1 of 1

Refreshing ActiveForm using .VBS Script

Posted: Wed Feb 17, 2016 4:38 am
by cipher
hi All,

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
I am using following Code in .VBS SCript to Open Excel ActiveForm. .VBS Scripts is also placed in the same folder as ExcelActiveForm.xlsm.

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.
Error pops up when I try opening Excel ActiveForm through .VBS Script
Error pops up when I try opening Excel ActiveForm through .VBS Script
n_connect_error.jpg (29.23 KiB) Viewed 2096 times
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.

Re: Refreshing ActiveForm using .VBS Script

Posted: Fri Feb 26, 2016 8:13 am
by babytiger
Were you using the service account to run this?