09-16-2005 10:37 AM
09-18-2005 04:33 PM
09-19-2005 10:49 PM - edited 09-19-2005 10:49 PM
Message Edited by Philip C. on 09-19-2005 10:51 PM
03-27-2020 02:39 AM
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
03-27-2020 01:59 PM
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.
03-29-2020 01:12 AM
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).
03-29-2020 03:25 AM
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?
03-29-2020 12:25 PM - edited 03-29-2020 12:54 PM
@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%.