Page 1 of 1

Keep getting "Type Mismatch" error using Excel Eviews Add-in

Posted: Tue Feb 12, 2013 9:22 am
by MrGoodwill
I can use the "Get Data" function just fine, but as soon as I press on Manage or Refresh All, I get an error box saying Type Mismatch.

Any help?

Re: Keep getting "Type Mismatch" error using Excel Eviews Ad

Posted: Tue Feb 12, 2013 10:03 am
by EViews Steve
MrGoodwill:

The Excel Add In that is provided by EViews 7 is a small add-in that was written using Visual Basic for Applications (VBA). It was written as an example of how you can use our OLEDB driver to access data, and as such, the source code is not hidden or protected at all. If you press Alt-F11 within Excel, it will bring up the VBA editor which will allow you to see our source code and even make changes.

Now as to your error, it would be difficult for me to guess what could be causing your error without known the version of Excel you are running it on, your version of Windows, and also the build date of EViews 7 that you have installed. Since you are getting a specific error, you could have even provided the name of the VBA module or class that the error is occurring in and also the line number (or at least the name of the method or sub). In the future, when you are asking for help, you should provide these kinds of details.

Now, my guess is that you are using Office 2010, which wasn't readily available when we originally released our add-in. I've noticed that VBA seems to run with a bit more restrictions under 2010 than it did in the past. The problem I've seen is that any code that uses ActiveSheet or ActiveWorkbook directly in a "For Each" loop can cause this the Type Mismatch error.

So anywhere in the code that looks like this:

Code: Select all

Dim qt As QueryTable For Each qt In ActiveSheet.QueryTables
has to be broken up into a few more lines like this:

Code: Select all

Dim qt As QueryTable Dim wrk As Worksheet Set wrk = ActiveSheet Dim qts As QueryTables Set qts = wrk.QueryTables For Each qt In qts
which in effect is exactly the same as before but with the For Each call using an explicit Worksheet and QueryTables object instead of ActiveSheet directly.

In any case, there are a few of these in the VBA code. You can make the changes yourself, or you can download this file that I've modified:
http://eviews.com/Forum_support/EViews%20Add%20In.xla

To install this new version, the easiest thing to do is to copy the "Excel Add In.xla" file into your EViews7 subdirectory (there should already be one there, just overwrite it), then run EViews 7 and type in "REGCOMPONENTS", then click Yes to re-register everything and this should re-copy the new add-in file to your Office Add Ins folder.

If this doesn't fix your problem, please provide the details I asked for above...

Steve

Re: Keep getting "Type Mismatch" error using Excel Eviews Ad

Posted: Tue Feb 12, 2013 12:53 pm
by MrGoodwill
Thank you Steve, one second as I try this.

Re: Keep getting "Type Mismatch" error using Excel Eviews Ad

Posted: Wed Feb 13, 2013 11:37 am
by MrGoodwill
Thank you Steve.

I replaced the file in the Eviews7 directory with the one you gave me, but the problem persists.

My OS is: Windows 7 Enterprises, Service Pack 1
My Excel version is: MS Office Professional Plus 2010, Version: 14.0.6126.5000 (32-bit)
My EViews version is: Version 7.2, Enteprise Edition - May 29 2012 build


I would love to give you the exact VBA method and line where the problem is occuring, but unlike usual macro bugs, no VBA window pops up when the error occurs. Nothing occurs on the VBA editor when I have it open when I get this error (which again, occurs when I click either on Refresh All or Manage).

Thank you.
A

Re: Keep getting "Type Mismatch" error using Excel Eviews Ad

Posted: Tue Feb 26, 2013 1:50 am
by ericcam
Hello.

I have exactly the same issue. It's because my regional setting is French. So i use the comma as a decimal separator.

In the function IsOffice2007OrAbove change the line:
d=CDbl(Excel.Application.Version)
by
d=Val(Excel.Application.Version)

The function Val is not dependant of the regional settings.
That should solve your issue.

Eric