12-09-2013 03:39 AM
Hi Everyone,
I am writing and reading data from an Excel file (see code) and it works but I have to specify the path in the script and if I want to change the file I have to change the file path in the code.
I would like to create a window that pops and asks the user to pick the excel file he wants to work with, copy the path and replace
"C:\Users\Public\Documents\National Instruments\DIAdem 2012\Documents\Constant Radius\USED\Test.xlsx" by that path.
I hope someone can give me a hand with this.....
Thanks
Leo
Dim Excel,a Set Excel = CreateObject("Excel.Application") Excel.Visible = TRUE Call Excel.Workbooks.Open("C:\Users\Public\Documents\National Instruments\DIAdem 2012\Documents\Constant Radius\USED\Test.xlsx") a=Excel.ActiveSheet.Cells(1,1).Value Excel.ActiveSheet.Cells(1,4).Value = RV1(1) Excel.ActiveSheet.Cells(2,4).Value = RV1(2) Excel.ActiveSheet.Cells(3,4).Value = RV1(3) Excel.ActiveSheet.Cells(4,4).Value = RV1(4) Excel.ActiveSheet.Cells(5,4).Value = RV1(5) Excel.ActiveSheet.Cells(6,4).Value = RV1(6) Excel.ActiveSheet.Cells(7,4).Value = RV1(8) Excel.ActiveSheet.Parent.Saved = FALSE Excel.Quit Set Excel = Nothing
Solved! Go to Solution.
12-09-2013 06:22 AM
Dim Excel,a Set Excel = CreateObject("Excel.Application") Excel.Visible = TRUE Call Excel.Workbooks.Open("C:\Users\Public\Documents\National Instruments\DIAdem 2012\Documents\Constant Radius\USED\Test.xlsx") a=Excel.ActiveSheet.Cells(1,1).Value Excel.ActiveSheet.Cells(1,4).Value = RV1(1) Excel.ActiveSheet.Cells(2,4).Value = RV1(2) Excel.ActiveSheet.Cells(3,4).Value = RV1(3) Excel.ActiveSheet.Cells(4,4).Value = RV1(4) Excel.ActiveSheet.Cells(5,4).Value = RV1(5) Excel.ActiveSheet.Cells(6,4).Value = RV1(6) Excel.ActiveSheet.Cells(7,4).Value = RV1(8) Excel.ActiveSheet.Parent.Saved = FALSE Excel.Quit Set Excel = Nothing
Hi,
I am just repasting the code. I don't know what happened earlier but everything went on the same line, sorry
12-09-2013 03:59 PM
Hi Leillo,
I believe this is what you're looking for:
DlgTitle = "Insert File Dialog Title Here..." StartPath = ProgramDrv & "Examples\Data\" FileExts = "*.XLSX,*.XLSX" FileExts = "Excel Files,*.XLSX;*.XLS" Call FileNameGet("Any", "FileRead", StartPath, FileExts, "Nul", True, DlgTitle) IF DlgState = "IDCancel" THEN Call AutoQuit DataFilePath = FileDlgFileName MsgBox DataFilePath
Brad Turpin
DIAdem Product Support Engineer
National Instruments
12-10-2013 03:11 AM
Thanks Brad, it worked OK