LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Return array from VBA Sub to Labview with Excel Run Macro VI

Hi everybody,

 

I try to use the Excel Report - Run Macro VI with a VBA Macro (My_Macro) structured as follow :

 

Sub My_Macro(A, B, C, D)

    Dim Chart_name() As String

   .....

 

End Sub

 

Function blabla()

    ...

End Function

 

In the code I build an array of strings and I would like this array to be returned to Labview. I do not know how to do that.

When I write Sub My_Macro(A, B, C, D) As String the code does not run anymore.

 

Please could you help with this.

 

Cheers,

0 Kudos
Message 1 of 4
(3,416 Views)

Can you post your VBA code that builds and returns the array?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 4
(3,405 Views)

Assuming this is your VBA code in a workbook called Book2.xlsm:

Function Macro1()
'
    Dim StringArray(1 To 2) As String
    StringArray(1) = "Test"
    StringArray(2) = "Test3"
    Macro1 = StringArray
    
End Function

This Labview code should run and return an array with those values. 

Capture.PNG

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 4
(3,394 Views)

Hi aputman,

 

Thank you for your answer.

I found on the internet that it was not possible to return something with Sub() in VBA so I used Function() instead ans it works.

0 Kudos
Message 4 of 4
(3,369 Views)