LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open Excel book and select sheet

I need to be able to open an Excel book, select a sheet, and write to a cell. Using the NI examples I've been able to open the excel book but I can't get it to select a sheet within the book. What is the proper way to do this?
0 Kudos
Message 1 of 7
(12,859 Views)

If you are starting with the example Write Table to XL, just change the Workbooks->Add to Workbooks->Open.  Then change the Sheets->Add to Sheets->Item.  The variant that is returned needs to be converted to a Worksheet type just like in the example.  The Index input is a variant and can accept either an integer sheet index or a string sheet name.

If you are expecting the specified sheet to be displayed by the ActiveX Item method, you won't see it.  The reference allows direct read/write of sheet contents without it being visible.  If you need to see it, use the Worksheet->Activate method.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
Message 2 of 7
(12,850 Views)

Hi Michael

 

 I have a few problems with the examples when I try to open XL, it opens continuously and never stops how can i make that excel only open one time ? Because when I run the other examples, I have the same problem it is always opening new windows so I can't work with 'em

0 Kudos
Message 3 of 7
(10,935 Views)
Are you clicking on the Run Continuously button in the toolbar? If so, don't. If not, then please provide more information. The example will open Excel. If you have the front panel control set to "Leave Excel open" then if you run it again it will create a new workbook. Are you opening Excel yourself?
Message 4 of 7
(10,925 Views)

Hi smercurio_fc

 

   Yes, I was doing that. But when i will make the executable, Will I  have the same problem? I think it will run as if I clicked on "Run Continously" right?

 

 

0 Kudos
Message 5 of 7
(10,902 Views)
You should NOT be using the Run Continuously button unless you are doing specific kinds of debugging. A normal VI should use the Run (once) button. If the VI needs to continue running you should use a loop.
Message 6 of 7
(10,899 Views)
Hey man thanks for your answers !
0 Kudos
Message 7 of 7
(10,887 Views)