VBA Com automation

For questions regarding programming in the EViews programming language.

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

Silvana
Posts: 13
Joined: Fri Jun 10, 2011 2:57 pm

VBA Com automation

Postby Silvana » Thu Aug 22, 2013 7:55 am

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

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

Re: VBA Com automation

Postby EViews Steve » Thu Aug 22, 2013 8:13 am

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

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

Re: VBA Com automation

Postby EViews Gareth » Thu Aug 22, 2013 8:30 am

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.

Silvana
Posts: 13
Joined: Fri Jun 10, 2011 2:57 pm

Re: VBA Com automation

Postby Silvana » Thu Aug 22, 2013 10:26 am

Yes. Thanks for pointing out that current directory problem. @runpath wouldn't make sense. Great tip about running a .prg text file. Thanks again.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests