Discussion:
Opening an Excel workbook using .NET Interop Assemblies
(too old to reply)
mesmith-nm
2005-07-18 21:10:51 UTC
Permalink
Brian,
 
Next question - why can't I see the properties that should be exposed by the Workbook object returned from the Workbooks.Add method? - see attached VI - sorry for the endless list of questions, but this behavior seems really odd.


excelExample.vi:
http://forums.ni.com/attachments/ni/170/132090/1/excelExample.vi
mesmith-nm
2005-07-19 14:40:49 UTC
Permalink
Well, it was worth a try - If I use the To More Specific Class node and cast from  the Workbooks type to the _Workbooks type, the methods and properties are exposed as expected, but then LabVIEW squawks and says -
"Error 1057 occurred at  in excelExample.vi
Possible reason(s):
LabVIEW:  Type mismatch: Object cannot be typecasted to the specified type."
I imagine that means I'm stuck trying to access these methods/properties directly through LabVIEW - or do you have any other ideas?  My fallback will be to wrap these properties in a .NET DLL that I can call from LabVIEW.
Thanks,
Mark
 
 
 
Lycangeek
2005-07-19 15:40:43 UTC
Permalink
Argh. Well, I did some more playing around and the good news is you should be able to get it working with a much smaller assembly helper than one that wraps all the properties. The To More Specific seems to be hitting that same bug because again it is working fine in my current development version. Try creating a simple wrapper to do the cast for you. Something like
 
_Workbook ConvertMe(WorkBook arg)
{
   return (_Workbook)arg;
}
 
Then you can call this assembly to get the other COM interface that has the methods and properties defined on it.
Loading...