Page 1 of 1

VBA Com automation

Posted: Thu Aug 22, 2013 7:55 am
by Silvana
Hi. I'm using Eview7 and I'm just beginning to work with COM automation in VBA.

I have this set of commands in my program:

%currpath = @runpath
cd %currpath

In VBA I tried
app.Run ("%currpath = @runpath")
app.Run ("cd %currpath")

the first works but "cd %currpath" gives the error "Path or file not found: URRPATH in "CD URRPATH"

Do I need to use some combination of app.run and app.get?

Thanks, Silvana

Re: VBA Com automation

Posted: Thu Aug 22, 2013 8:13 am
by EViews Steve
Sending EViews commands thru the Run method is just like typing in the commands into the EViews command window.

And when you're using the EViews command window, you can't use variables like you can in an EViews program. So that means you have to create a program to do what you want, then run the program. You can create a text file (with a .PRG file extension) with the commands you want to run, then run the text file as a program.

Code: Select all

app.Run("run c:\mytest.prg")
Steve

Re: VBA Com automation

Posted: Thu Aug 22, 2013 8:30 am
by EViews Gareth
As an aside, I'll add that the @runpath command returns the path from where the currently running EViews program is being stored. Since, as Steve points out, COM uses individual commands, and not EViews programs, @runpath will do nothing when issued from COM, unless it is included in a .prg file, and then COM is used to run the .prg.

Re: VBA Com automation

Posted: Thu Aug 22, 2013 10:26 am
by Silvana
Yes. Thanks for pointing out that current directory problem. @runpath wouldn't make sense. Great tip about running a .prg text file. Thanks again.