11-30-2006 04:13 PM
12-03-2006 08:10 PM
12-04-2006 11:30 AM
I have attached a zip file with these files
Chart Data File.vi - This VI creates some data and saves the data into "Data File.xls". Its a tab-delimited file
Data File.xls - This is the file containing the data from your LabVIEW application
ProcessDataFile.xls - This spreadsheet is loaded by Chart Data File.vi. It contains the macro to load.
ChartDataFromFile-Original.txt - This the original macro I recorded to load the file into Excel,select range, chart, resize and reposition chart in column in order.
In this case a lttle more work is required to completely automated the loading of the data file and to create 3 charts from the data. I modified the VBA Procedure ChartDataFromFile() to use an string argument which is the path of the data file. This allows me to automate Workbooks.OpenText. The next thing is that ActiveChart.SetSourceData uses a fixed range A1:101, for example. To get around this I created a range object variable rngMeasRange to store the current selection which can then be used to automate ActiveChart.SetSourceData also. You can see the changes from the original macro in "ChartDataFromFile-Original.txt" to the more automated version in ProcessDataFile.xls using the VBA Editor.
This example vi uses sub-vis from ExcelExamples.llb so you will need to add examples to your vi search path under Tools -> Options. Alternatively you can load up Excel Macro Example.vi from Example Finder to make sure the sub-vis are loaded already in memory before you load Chart Data File.vi.
Hope this gives you an idea of the power of labview and excel vba together.
David
12-05-2006 04:19 PM