Calling an ActiveX Object from LabVIEW

Use an automation refnum if you do not want to embed an ActiveX object or control in the LabVIEW front panel window.

Complete the following steps to call an ActiveX object from LabVIEW.

  1. Add an automation refnum control to the front panel window.

     Add  Find
  2. Associate an ActiveX object with the automation refnum control.
    1. Right-click the control and select Select ActiveX Class»Browse from the shortcut menu to display the Select Object From Type Library dialog box.
    2. Select a type library from the top pull-down menu of the Select Object From Type Library dialog box.
    3. Select an object from the Objects box and click the OK button.
  3. Open a reference to the automation refnum.
    1. Add the Automation Open function to the block diagram.

       Add  Find
    2. Wire the automation refnum to the Automation Refnum input of the Automation Open function.
  4. Access a property or invoke a method on the automation refnum.
    1. Add one of the following nodes to the block diagram.
    2. Wire the Automation Refnum output of the Automation Open function to the reference input of the node.
    3. Click the node to display a list of the properties or methods available for the referenced object.
      Note Note  If LabVIEW does not display the properties or methods that you expect for the referenced ActiveX object, the object might implement multiple Component Object Model (COM) interfaces. LabVIEW can display the properties or methods from only one COM interface implemented by the object at a time. You can force LabVIEW to display the properties and methods from a different COM interface that the object implements by using the Variant to Data function to cast the automation refnum to the other COM interface.
    4. Select a property or method.
Note  Not all ActiveX objects expose methods.
  1. Close the reference to the ActiveX object.
    1. Add the Close Reference function to the block diagram.

       Add  Find
    2. Wire the reference out output of the Invoke Node to the reference input of the Close Reference function.
  2. Run the VI. The Automation Open function opens a reference to the ActiveX object you requested in the automation refnum control in the front panel window and performs the method you requested in the Invoke Node.