Page 1 of 1

Com Automation, VB Script, System Objects

Posted: Fri Apr 29, 2011 6:46 am
by Ravi
I am using EViews COM automation in order to invoke EViews from a VB script.
I am using the script to extract the residuals of a system object.
for that I have the following lines in my script

Code: Select all

equations = app.Lookup("*","system",1) For Each equation In equations command = "" & equation & ".makeresids script_temp" app.Run(command) command = "freeze(mode=overwrite,script_temp2) script_temp" app.Run(command) command = "script_temp2.save " & C:\\Work\\ACT_FIX_RES\\" & equation & ".makeresid" app.Run(command) next

However I Get the following error,
EViews.Application.1.Run: SCRIPT_TEMP is not a series in "DO_ SYST_OBJ1.MAKERESIDS SCRIPT_TEMP
SYST_OBJ1 is the first system object in my eviews work file.

I am still a beginner at eviews so pardon me if I have misused any terms

Version : Eviews 7

-Ravi

Re: Com Automation, VB Script, System Objects

Posted: Fri Apr 29, 2011 7:52 am
by EViews Gareth
Try doing:

Code: Select all

_ SYST_OBJ1.MAKERESIDS SCRIPT_TEMP
directly in EViews, rather than through COM.

Re: Com Automation, VB Script, System Objects

Posted: Fri Apr 29, 2011 10:46 am
by Ravi
A pop up titled Make Residuals pops up
with options for ordinary,cholesky of covariance,square root of covariance and square root of corelation pops up.
When i select ordinary and select OK , I do get the residual series.

Why is it not working from COM? any Ideas?

Re: Com Automation, VB Script, System Objects

Posted: Fri Apr 29, 2011 10:57 am
by EViews Gareth
Our COM guy is not in today. I'll make sure he takes a look on Monday though.

Re: Com Automation, VB Script, System Objects

Posted: Tue May 03, 2011 4:03 am
by Ravi
Hi Gareth,
Any Updates?

Re: Com Automation, VB Script, System Objects

Posted: Tue May 03, 2011 8:05 am
by EViews Steve
I just ran a small test of your code sample, and with some slight changes for formatting, it worked for me just fine. Here's my code sample (I ran this under Excel 2007).

Code: Select all

Sub test() On Error GoTo ErrorHandler Dim mgr As New EViews.Manager Dim app As EViews.Application Dim command As String 'on my desktop, I already had EViews with a workfile already open... Set app = mgr.GetApplication(ExistingOnly) equations = app.Lookup("*", "system", 1) For Each equation In equations command = "" & equation & ".makeresids script_temp" Call app.Run(command) command = "freeze(mode=overwrite,script_temp2) script_temp" Call app.Run(command) 'You don't need to double-up the backslashes when it's in a VBA string... command = "script_temp2.save C:\files\" & equation & ".makeresid" Call app.Run(command) Next ErrorHandler: Set app = Nothing Set mgr = Nothing End Sub
If this code fails for you at the same place (for your workfile), please send me a copy of the workfile to steve@eviews.com.

Steve

Re: Com Automation, VB Script, System Objects

Posted: Wed May 04, 2011 10:51 am
by Ravi
Hi Steve,
Thanks for your help.
I will try out your script soon and get back with the results

Also if it helps you debug I am running the script as extract.vbs and executing it along cscript.exe and my eviews version in 7.2

Re: Com Automation, VB Script, System Objects

Posted: Wed May 04, 2011 12:51 pm
by EViews Steve
As long as you're not running on a 64-bit OS, my code sample should be fine to be run from a VBS script...