Showing results for 
Search instead for 
Did you mean: 
Reply

Open Excel book and select sheet

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 (7,817 Views)
Reply
0 Kudos

Re: Open Excel book and select sheet

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, ABCDEF
Certified LabVIEW Developer, MCP
Automate 50+ VI Search and Edit operations with Property Inspector 2.0, now with Quick Drop compatibility!
Message 2 of 7 (7,808 Views)

Re: Open Excel book and select sheet

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 (5,893 Views)
Reply
0 Kudos

Re: Open Excel book and select sheet

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 (5,883 Views)

Re: Open Excel book and select sheet

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 (5,860 Views)
Reply
0 Kudos

Re: Open Excel book and select sheet

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 (5,857 Views)

Re: Open Excel book and select sheet

Hey man thanks for your answers !
0 Kudos
Message 7 of 7 (5,845 Views)
Reply
0 Kudos
//this script is to ensure MY ACCOUNT is loaded and then paste the info into the nav