Showing results for 
Search instead for 
Did you mean: 

How to Get OLE Variant Type?

How can I obtain the type of an OLE variant?  Using the "Variant to String" function always returns a type descriptor of "reference".  Looking at the control, the "Variant Type" attribute is present.  I found a previous thread here, but with no responses.


Since the OLE variant is a "reference", closing and re-opening the a VI will "lose" the data contained within the indicator.  Therefore, I cannot post a VI for testing of this.


The type is necessary so I can call the proper "Variant to Data" function.  My current work-around is to call the "Variant to Data" for all of the possible types (see image below) until I get an error.



Any help or advice would be appreciated!

Download All
0 Kudos
Message 1 of 9

I don't know if they'll work for OLE Variant Data, but see if any of the functions in vi.lib\utility\VariantDataType\VariantType.lvlib can get you the information you need.  I'd try "Get Type"  If that fails, you could try converting the variant directly to a string (with variant to data) and then look at that string to see if it tells you anything.  I had to do this with a complex type returned by an ActiveX call - all I could get from it was a string that I then had to parse into real data following the matching C structure definition.

0 Kudos
Message 2 of 9

I tested various functions with the info shown below:


1. vi.lib\utility\VariantDataType\Get Type

Returns "array" for everything


2. Flatten to string returns the same data for everything




The "variant type" attribute is displayed properly in a LabVIEW indicator.  There must be a way to access it...


Any other ideas?

Message 3 of 9
0 Kudos
Message 4 of 9

There is a library from MGI that might be useful for this.  Take a peek at the Cluster>VariantDataType pallette.

0 Kudos
Message 5 of 9



No luck...


The MGI toolkit calls VIs in the vi.lib\Utility\VariantDataType\ directory.  I gave every VI a try in the pallete.  None of them return the type of data contained in the OLE variant.  The majority of them return Error 1.  The GetTypeInfo returns "External Data".

0 Kudos
Message 6 of 9

The solution to this is to use a Call Library Node to call the LabVIEW manager function MoveBlock().

Configure the first parameter to be an ActiveX Variant, second parameter is an 16 bit integer passed as pointer to value, and the third is a 32 bit integer passed as value.


The function is in this post, with the name Get OLE Variant

Rolf Kalbermatter
Averna BV
0 Kudos
Message 7 of 9

Rolf, can you re-post your Get OLE Variant here?  It is no longer available on the LAVA post.

0 Kudos
Message 8 of 9

I’m on vacation with no access to my computer. But the description earlier should be almost all you need.

Call Library Node: Library Name: LabVIEW (case is important). Calling Convention: C

Function Name: MoveBlock

return value: void

1st Parameter: Active X Variant

2nd Parameter: uint16, passed as Pointer

3rd Parameter: pointer sized integer, passed by value

wire the Variant to the first Parameter and a constant with the value 2 to the third. The second parameter returns a value that matches the VT_ values from MSDN.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 9 of 9