Page 1 of 1

how to call an EViews program file from Excel VBA?

Posted: Wed Nov 30, 2011 2:09 pm
by please_work
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.

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

Posted: Wed Nov 30, 2011 2:13 pm
by EViews Gareth
Did you try changing "wfopen" to "run"?

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

Posted: Wed Nov 30, 2011 2:26 pm
by please_work
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

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

Posted: Wed Nov 30, 2011 3:03 pm
by please_work
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

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

Posted: Wed Nov 30, 2011 3:36 pm
by EViews Steve
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