02-16-2016 06:41 AM
Andreas
I have been in contact with Brad and Otmar.
We were able to access functions within an .xla file we created by using the Excel.Application.Run() function. This allowed us to call a function with an open workbook.
However there are a couple of drawback to this work around.
1) All of the function within our .xla document need to have there prototypes edited to where the input can only be "Variant" as opposed to "string" "Boolean" etc.
So where we had Function OpenData(filename As String) we now have Function OpenData(filename As Variant)
Not a huge change but not ideal.
2) We are opening an .xla document by creating an excel object and opening it. This references a .dll the equipment manufacturer has developed to allow applications such as LabVIEW, Matlab, and VBA to access these functions. In Matlab we simply make reference to the .DLL and we have access to these functions. The ideal solution is to modify this .DLL such that it could be added to DIAdem as a GPI extension. I have sent Brad a copy of this .dll and I am hoping that he will be able to generate a GPI extension usable in DIAdem.
Thanks for your response.
03-01-2016 02:23 PM
Success!
I have found a way to use the existing VBA code through DIAdem without the need to modify the existing VBA code.
The process is as follows below.
First I needed to declare a create an excel Object
Dim excel, excelbook Set excel = CreateObject("Excel.Application") Set excelbook=Excel.Workbooks.Open("filepathway and name")
I then needed to run the VBA application function and pass the function name and prototypes to excel the excel object. because my prototype's in VBA specify the data type for input I was having problems passing variant data types to declared data types. I was able to overcome this by parsing the data in the function call.
TestInfo = excelObject.Application.Run("FunctionNameinVBA", cstr(String Variable), clng(long variable))
This enables me to return one non array type data back to VBS.
Return data type of arrays has been a little more challenging as I needed to use the ArrayToChannels() function but I have had limited success in getting this to work.