LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX and Excel Plotting

Solved!
Go to solution

Hello,

 

I have a question regarding ActiveX and Excel Plotting.  I know how to add a series to a plot using ActiveX in LabVIEW, but what I would like to do is add multiple series at once.

 

In Excel, in the first column I have the X-values which will be the same for all the series.  Each subsequent column will be different values.  I selected all the data, created a plot, click "Select Data" and then Switch Row/Column.  This gave me the plots I was looking for.  

 

I recorded my steps.  Here is the VBA code:

 

Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterLinesNoMarkers).Select
ActiveChart.SetSourceData Source:=Range("'X'!$A$2:$BX$62")
ActiveChart.PlotArea.Select
Application.CutCopyMode = False
ActiveChart.SetSourceData
ActiveWindow.ScrollRow = 1

 

I was hoping I could recreate this code in LabVIEW.  I've come as far as "ActiveSheet.Shapes.AddChart2(240, xlXYScatterLinesNoMarkers).Select", but I can't figure out how to select the data for the active chart now.

 

I am using LabVIEW 2016.

 

Thanks, Natalie

 
 

 

 

 

 

 

0 Kudos
Message 1 of 4
(1,314 Views)

You can create an Excel template, and put those VBA code in it.

In LabVIEW, all you need to do is dump the data to Excel, let Excel do the plotting.

 

George Zou
0 Kudos
Message 2 of 4
(1,289 Views)

Thanks.  I'd prefer to have it done in LabVIEW for this application, though.

0 Kudos
Message 3 of 4
(1,285 Views)
Solution
Accepted by topic author _natalie_

I've figured out by adding a plot, creating a range that covers all of the data and used that to SetSourceData.  It plots everything at once, so I won't have to loop through all the columns and add individual series.

 

I attached a snippet of my code.ActiveX-Excel Plotting.PNG

0 Kudos
Message 4 of 4
(1,275 Views)