Refreshing ActiveForm using .VBS Script

Post Reply
cipher
Posts: 13
Joined: Thu Jan 08, 2015 6:15 am
OLAP Product: TM1
Version: 9.5.2 10.2.2 64 Bit
Excel Version: 2010

Refreshing ActiveForm using .VBS Script

Post 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 2042 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.
babytiger
Posts: 78
Joined: Wed Jul 31, 2013 4:32 am
OLAP Product: Cognos TM1, EP, Analyst
Version: 10.2.2
Excel Version: 2013
Location: Sydney AU

Re: Refreshing ActiveForm using .VBS Script

Post by babytiger »

Were you using the service account to run this?
MK
Post Reply