how to call an EViews program file from Excel VBA?

For questions regarding programming in the EViews programming language.

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

please_work
Posts: 8
Joined: Wed Dec 15, 2010 9:07 am

how to call an EViews program file from Excel VBA?

Postby please_work » Wed Nov 30, 2011 2:09 pm

Hello,

I am looking for an example to get me started running EViews programs from Excel VBA. I have seen the white paper and some of the posts related to calling and working with workfiles, but did not see anything with the .prg files.

Below is what I have for workfiles, could someone please help me adjust this to work with EViews program files? I am working with version 7.

Dim program_to_call As String
program_to_call = "C:\program_file"

'Open connection to EViews
Dim mgr As New EViews.Manager
Dim app As EViews.Application
Set app = mgr.GetApplication(ExistingOrNew)

app.Run "wfopen " & program_to_call

Any help would be greatly appreciated.

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

Re: how to call an EViews program file from Excel VBA?

Postby EViews Gareth » Wed Nov 30, 2011 2:13 pm

Did you try changing "wfopen" to "run"?

please_work
Posts: 8
Joined: Wed Dec 15, 2010 9:07 am

Re: how to call an EViews program file from Excel VBA?

Postby please_work » Wed Nov 30, 2011 2:26 pm

Thanks - I did and it did call EViews.

However, it gave me the following error message

Run-time error '-2147023170 (800706be)':
Automation error
The remote procedure call failed

Any suggestions?

Thanks

please_work
Posts: 8
Joined: Wed Dec 15, 2010 9:07 am

Re: how to call an EViews program file from Excel VBA?

Postby please_work » Wed Nov 30, 2011 3:03 pm

I was able to get this to work without activating EViews Manager

Set objShell = CreateObject("Wscript.Shell")
objShell.Run ("C:\EViews_program.prg")

Is there a location with a complete list of the command strings for EViews applications? Application.Run in particular

If possible, I would like to close all of the EViews workfiles and the program I called when it is finished.

Many thanks

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

Re: how to call an EViews program file from Excel VBA?

Postby EViews Steve » Wed Nov 30, 2011 3:36 pm

Application.Run is just like typing into the command window in EViews itself. Anything you can type into the EViews command window, you can pass to Application.Run.

So if you refer to our EViews Command Reference, you get a list of all available commands...

By the way, about your Remote Procedure call failure, that can happen if EViews crashes or the instance isn't there anymore when you make the call. If you can reliably recreate this problem, send me a sample VB script that does this and I'll try to debug it for you.

Steve


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests