12-22-2020 09:23 AM
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
Solved! Go to Solution.
12-22-2020 12:22 PM
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.
12-22-2020 12:32 PM
Thanks. I'd prefer to have it done in LabVIEW for this application, though.
12-22-2020 01:25 PM
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.