Page 1 of 1

Problem with Eviews COM Automation

Posted: Wed May 15, 2013 1:56 am
by bigmonty
I was experimenting with Eviews COM Automation tool. I wrote the following code in VB.NET to call a Eviews workfile from VB.

Code: Select all

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim mgr As New EViews.Manager Dim app As EViews.Application app = mgr.GetApplication(EViews.CreateType.NewInstance) app.Run("wfopen J:\Hans\MOF\EViewsStuff\macmod.wf1") End Sub
After I run the code I get a form with a button. I click the button but nothing happens. I understand that I have to find a way to display the object but not sure
how to do that. Any help would be highly appreciated.

Re: Problem with Eviews COM Automation

Posted: Fri May 17, 2013 2:32 pm
by EViews Steve
That's actually a feature. A lot of COM users would prefer that the application they're controlling does NOT show up on the user's desktop because they only want to use it as a resource for their own application.

In any case, the answer you're looking for is:

Code: Select all

app.Show()
This will make the application appear. This does mean that when you are done with EViews and your program quits, EViews will hang around until someone manually closes it. Only hidden instances of EViews will automatically quit when their COM client is finished with it.

You can call:

Code: Select all

app.Hide()
to re-hide the application.

Steve

Re: Problem with Eviews COM Automation

Posted: Sat May 18, 2013 9:17 pm
by bigmonty
Thanks a lot Steve for your answer. I have another question for you if you don't mind.

Code: Select all

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim myVar myVar = TextBox1.Text Dim mgr As New EViews.Manager Dim app As EViews.Application app = mgr.GetApplication(EViews.CreateType.NewInstance) app.Run("wfopen J:\Rushad\MOF\macmodr2.wf1") app.Run("show myVar") app.Show() End Sub
In the above VB.net code, I want the user to enter the name of the variable in the TextBox1 which is saved as myVar and then I want to display myVar in
the subsequent app.Run("show myVar") command. But the problem is myVar is not recognized by the instruction passed on to Eviews. How to get around that
problem?

Re: Problem with Eviews COM Automation

Posted: Sun May 19, 2013 4:37 pm
by EViews Steve
If you use the code:

Code: Select all

app.Run("show myVar")
that command is just like typing in the string "show myVar" inside the EViews command window. Assuming your workfile doesn't have an object named "myVar", EViews wouldn't know what to do with that command.

What you meant to do is use the value of myVar instead of the literal string "myVar" in your run command. This means you have to build a string that starts with "show " and then ends with the value of myVar. To do that in VB.NET, you would do this:

Code: Select all

app.Run("show " & myVar)
Steve