Page 1 of 1

COM Automation Snag

Posted: Mon Mar 12, 2012 1:39 pm
by NewbGrammer
Hello,

I'm using Eviews 7.2 to try to write some VBA code to write a certain range of Excel Cells into an Eviews workfile.

Here's where I'm at so far:

Sub eviews()

Dim mgr As New EViews.Manager
Dim app As EViews.Application
Set app = mgr.GetApplication(EViews.CreateType.ExistingOrNew)

app.Show
app.ShowLog

app.Run "wfopen K:\non-data-path-folder\workfile.wf1"
app.Run "run K:\non-data-path-folder\Programs\program.prg"

End Sub


The wfopen command seems to be defaulting to the data path and I can't figure how to either temporarily change the data path or allow the command to look for the workfile in a different place.

If I "comment out" the wfopen line, I still cannot get the program to run. Eviews seems almost unresponsive to my attempt. I do not know where I'm misunderstanding the app.run (CommandString) concept.

Thanks for any help or tips.

Re: COM Automation Snag

Posted: Mon Mar 12, 2012 1:43 pm
by EViews Gareth
Is there a space in the path? I assume that this isn't the real path:

Code: Select all

K:\non-data-path-folder\workfile.wf1

Re: COM Automation Snag

Posted: Mon Mar 12, 2012 1:47 pm
by NewbGrammer
Correct, the filepaths above aren't the real ones. There is no space in either filepath, but one folder name is surrounded by parenthesis.

Eg: K:\(folder_name)\programs\program.prg

Re: COM Automation Snag

Posted: Mon Mar 12, 2012 1:51 pm
by EViews Gareth
The parenthesis are probably causing the problem, and it is probably a problem on our end. Could you try renaming the folder temporarily to see if that fixes it?

Edit: Actually it isn't a problem our end per se. You need to have the path surrounded in quotes whenever you have a parenthesis in the path, in the same way you would if you had spaces.

Re: COM Automation Snag

Posted: Mon Mar 12, 2012 1:58 pm
by NewbGrammer
Ahh that seems to be the issue. Thanks very much for the help. I'll try to get these folder names changed.

Re: COM Automation Snag

Posted: Mon Mar 12, 2012 2:25 pm
by EViews Steve
The Application.Run method is just a way to run an EViews command. The formatting of the command has to be an exact match to the command as if it was typed directly into the EViews command window.

This means you should be able to run the wfopen or the run command directly within EViews first. If it doesn't work there, it won't work via the COM interface.