Calling a LabVIEW VI and Passing Parameters from Microsoft Excel VBA via ActiveX

Updated Oct 9, 2026

Environment

Software

  • LabVIEW

This article explains how to call an NI LabVIEW™ VI from Microsoft Excel VBA through ActiveX Automation. It covers configuring the VI connector pane, passing scalar values, enums, and clusters, executing the VI, and retrieving output data. The example VI performs a finite NI-DAQmx analog acquisition using a simulated device, so the generated waveform data appears as a sine wave. The VI used in this example is shown below.
 

Part 1: Configure the LabVIEW VI Connector Pane

When calling a VI using the ActiveX Call method (vi.Call paramNames, paramValues), LabVIEW exchanges data only through controls and indicators assigned to the connector pane.

  1. Open the LabVIEW VI Front Panel.
  2. Locate the connector pane in the upper-right corner of the Front Panel window.
  3. Right-click the connector pane and select Patterns to choose a connector pattern with enough terminals for your inputs and outputs.
  4. Assign each input control and output indicator to a connector pane terminal by first clicking an unassigned (blank) terminal and then clicking the corresponding control or indicator.
  5. Verify that each terminal changes color according to its assigned data type.
  6. Save the VI.

For additional details and screenshots, refer to the Build the Connector Pane section of: Create and Configure a LabVIEW SubVI

Part 2: Configure VBA Parameter Arrays

The first parameter required by the Call() method is paramNames, which is an array containing the names of the LabVIEW Front Panel controls and indicators used as input and output parameters. The second parameter is paramValues, which is an array that contains the input values passed to the VI and stores the values returned by the output parameters. The elements in paramValues must correspond to the same order as the parameter names specified in paramNames.

Important considerations:

  • Parameter names must exactly match the connector pane control and indicator labels.
  • String values must be enclosed in quotation marks.
  • A LabVIEW cluster is represented as an array of Variants in Visual Basic.

Example:

 

Part 3: Create the LabVIEW Object and VI Reference

Create a LabVIEW ActiveX object using the CreateObject() function. Then create a variable containing the path to the VI you want to execute. Use the GetVIReference() method to load the VI into memory.
Example:

Part 4: Execute the VI

Use the OpenFrontPanel() method to display the VI Front Panel during execution, then use the Call() method to update the control values specified in the paramValues array and execute the VI. After execution, close the Front Panel if it is no longer needed.
Example:


Part 5: Retrieve the outputs generated by the VI

After the VI finishes running, use the GetControlValue() method to retrieve the output values from the VI. If the output is an array, you can use a VBA For loop to write each element to the Excel worksheet.
Example:

The complete Visual Basic code should resemble the following:

After running the code, the column A of the active Excel worksheet should contain the acquired numeric data. If you plot the values in Excel, you should observe a sine waveform generated by the DAQmx acquisition.