LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX changes in Excel versions?

I've created a VI in Labview 7.1 to pass data back and forth to Excel 2002 via ActiveX.
 
I then created an .exe of the VI and ran it on the same computer (with Excel 2002) with success.
 
However, when the .exe was run on a computer with Excel 2000, it did not work.
 
So...I tried to run the actual VI (not the .exe) on the computer with Excel 2000.  The VI came up with a broken arrow, claiming that one of the invoke nodes were wired inproperly.  There were however, no broken wires.
 
My question.....Are there ActiveX changes between Excel 2000 and 2002 that would prevent me from writing an application in one to be used with another?  If so, how did LabView know this before I ran the VI?
 
Any insight here?
 
---
BC 
0 Kudos
Message 1 of 8
(4,065 Views)
I have a developed app that writes extensively to Excel. I have found out the hard way that there are active-x funtional differencces between Excel 97/2000/2002/and 2003. All require alterations of the basic active-x control to run reliably. Of the versions, 2000/2002 seem to require the least modifications, followed by 97/2000. I have yet to completely de-bug 2003's version, so I do not know where it falls. The answer to your question is a resounding YES there are significant differences in the function calls in the 4 common versions of Excel. A first class P.I.T.A!! Good luck with yours, Dave
0 Kudos
Message 2 of 8
(4,052 Views)
Hi BC,

Yes, there are differences in the ActiveX API between every version of Microsoft Office. However, don't despair! It might be easier to fix your error than you think.

First of all, the reason that you get a broken arrow when opening the VI on the Excel 2000 machine is that LabVIEW reads the type library file (*.tlb) that belongs to the version of Excel that is installed on the machine. This file determines the available methods and properties of the Excel ActiveX server - in other words the ActiveX API needed to access Excel. If some of the methods or properties that were saved with the VI when it was created on the Excel 2002 machine are not present in the API for the Excel 2000 machine, LabVIEW will notify you with a broken arrow. Clicking the broken arrow will take you to the Invoke Node (for methods) or the Property Node (for properties... duh!) that has a mismatch between the method/property in the VI versus the one in the API. The wire will not be broken, so it might be confusing to see what is wrong the first time. However, all you have to do is use the finger tool to click on the Node to bring up a list of available methods/properties. Notice that the method/property that originally was showing in the Node is NOT part of the list, since this list is defined by the *.tlb file. What you should do is choose another method/property that will do what you need instead of the original one.

One of the most common issues between Excel versions were the change from using the "Value" property to using the "Value2" property between version Excel 97 and 2000 (as far as I remember). The fix was simply to choose "Value2" instead and the VI would then run fine.

Here's a KnowledgeBase that talks about some of these version specific issues with ActiveX and Excel:

LabVIEW's ActiveX Examples for Microsoft Excel 97 with Newer Versions of Microsoft Excel

BC, please let me know if this explanation helps you solve the issue, thanks.

Have Fun!

Message Edited by Philip C. on 09-19-2005 10:51 PM

- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
Message 3 of 8
(4,038 Views)

Hello everyone,

I am sorry to resurrect a old post but I am facing with I think the same problem.

I am using inside a my subVI the activeX functions saveAs and exportAsFixedFormat. They work perfectly however if I move the subVI in another machine with apparently the same Office version (what change is the language) it shows a broken arrow and i must open the subVI and select again the same two methods of the activeX.

I would like to build and distribuite an executable how can I avoid to have this issue?

Many thanks

0 Kudos
Message 4 of 8
(2,995 Views)

You could try using the .NET controls for Excel automation?

 

I think they're just wrappers for the ActiveX controls so all of the parameters and function names are the same for the most part.

 

Start Excel .NET.png

0 Kudos
Message 5 of 8
(2,982 Views)

When there is a change in Excel Version, you need to Relink the Method to support the Feature. In LabVIEW its common that we need to relink when the DLL gets updated (Accessing DLL using ActiveX).

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 8
(2,962 Views)

I have never used .NET so it add difficult and I suspect that just move the problem in another discussion.

 

Ok, to relink the method is normal (also if method is identical defined), is there a way to programmatically relink the method in an executable? I don't think. Is there a way to save my ActiveX version also in a machine where a different version is installed? I think it give licences problem.

Is there a solution?

0 Kudos
Message 7 of 8
(2,958 Views)

@ico82 wrote:

I have never used .NET so it add difficult and I suspect that just move the problem in another discussion.

 

Ok, to relink the method is normal (also if method is identical defined), is there a way to programmatically relink the method in an executable? I don't think. Is there a way to save my ActiveX version also in a machine where a different version is installed? I think it give licences problem.

Is there a solution?


No. LabVIEW programs are fully compiled and changing the code in an executable is not an option!

 

The only way to work around this if you need to support multiple Excel versions is to use dynamic loading.

You create a caller that uses VI Server to locate the correct VI for the currently installed Excel (and other Office application) version and then call it. You need to maintain also different VIs with the same calling interface for each version you want to support. And yes you only can create/modify each relevant VI on a system with the according Excel (Office) version. In order for the VIs to be executable in an executable they need to be compiled in the according LabVIEW version and the binary code needs not to be seperated from the VI. And that needs to be done for each Excel (Office) version you want to support too.

In terms of ease of maintenance this is a pretty terrible solution.

Not really easier but a lot more maintainable is likely to simply create an external DLL in C++ that does not change the API and call that Excel API from there. If you use proper COM/ActiveX mechanisme like IDispatch you can discover what the current method requires as parameters and pass to all the unused optional parameters a variant initialized as follows:

 

VARIANT var;
var.vt = VT_ERROR
var.scode = DISP_E_PARAMNOTFOUND.

 

Visual Basic (and VBA) does this automatically and that is why it seems to work, but in C++ you have to do that explicitedly and the LabVIEW interface for ActiveX is written in C++. The code generator determines the number of parameters at compile time and that is why it fails when the ActiveX method suddenly has a different number of paramters. Theoretically LabVIEW could do the determination of the ActiveX interface also at runtime through the IDispatch interface but that would be a serious performance hit as it would be something to do either for all ActiveX methods or none. Of course it could also allow to add a user selectable option if the method interface should be resolved with IDispatch at runtime or compile time and that would resolve this once and for all, but ActiveX is already a legacy technology and the likelyhood that NI is spending such significant development effort for a legacy technology is about 0.1%.

Rolf Kalbermatter
My Blog
Message 8 of 8
(2,946 Views)