Com Automation, VB Script, System Objects

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Ravi
Posts: 11
Joined: Fri Apr 29, 2011 6:22 am

Com Automation, VB Script, System Objects

Postby Ravi » Fri Apr 29, 2011 6:46 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Com Automation, VB Script, System Objects

Postby EViews Gareth » Fri Apr 29, 2011 7:52 am

Try doing:

Code: Select all

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

Ravi
Posts: 11
Joined: Fri Apr 29, 2011 6:22 am

Re: Com Automation, VB Script, System Objects

Postby Ravi » Fri Apr 29, 2011 10:46 am

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?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Com Automation, VB Script, System Objects

Postby EViews Gareth » Fri Apr 29, 2011 10:57 am

Our COM guy is not in today. I'll make sure he takes a look on Monday though.

Ravi
Posts: 11
Joined: Fri Apr 29, 2011 6:22 am

Re: Com Automation, VB Script, System Objects

Postby Ravi » Tue May 03, 2011 4:03 am

Hi Gareth,
Any Updates?

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Com Automation, VB Script, System Objects

Postby EViews Steve » Tue May 03, 2011 8:05 am

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

Ravi
Posts: 11
Joined: Fri Apr 29, 2011 6:22 am

Re: Com Automation, VB Script, System Objects

Postby Ravi » Wed May 04, 2011 10:51 am

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

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Com Automation, VB Script, System Objects

Postby EViews Steve » Wed May 04, 2011 12:51 pm

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...


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests