From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Select Excel Sheet & Cell

Solved!
Go to solution

I currently have several hundred excel files which each have 3 sheets.  Some of the files have been saved with the first sheet open, some with the second sheet open, and some with the third sheet open.  When one of these files is opened it automatically opens to the sheet that was displayed when it was saved last.

 

I need to write a LabVIEW program that opens each of these files, does some formatting, makes sure cell A1 is selected in each sheet, and make sure the first sheet is open when it is saved, so it opens with the first sheet showing.  I'm new to ActiveX, but I've already figured out the formatting, and I'm doing formatting in all 3 sheets.  I just can't figure out how to choose which cell is selected and which sheet is displayed.

 

Thanks for the help,

Jeremy

Jeremy Backer
CLAD
0 Kudos
Message 1 of 7
(4,752 Views)
Solution
Accepted by topic author JMBacker

Try the attached VI.   It was adapted from:

 

http://zone.ni.com/devzone/cda/epd/p/id/60

 

I had to change the cell contents of the desired sheet to keep that sheet on top when saved.  You probably could just change an attribute (font size, etc.) if changing the cell contents is undesirable.

 

 

Note: the selected sheet name on the front panel is the sheet that will be on top when opened.
Message Edited by vt92 on 04-13-2009 04:34 PM
>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 2 of 7
(4,733 Views)
Do you need to do any work on these Excel files that you actually need LabVIEW for?  If not, I would just create a VB macro in Excel saved in a separate that does what you need.  Then just open up each sheet and run the macro.  Recording the macro while you manually do the steps the first time should give you most of the code you need.  Then you can just edit the code if needed to tweak it.
0 Kudos
Message 3 of 7
(4,725 Views)

I don't think your advice would be to open each sheet and run the macro if you had several hundred sheets to open from several hundred folders Smiley Happy.  Through LabVIEW I can automatically open every sheet from all the different folders.  One button and they all get changed.  Plus, I'll be doing this on a regular basis, so the easier the better.

Jeremy Backer
CLAD
0 Kudos
Message 4 of 7
(4,706 Views)

Worksheet NamesJeremy

 

You can get the worksheet names and then get a reference to the selected worksheet .   

 

Message Edited by VADave on 04-14-2009 06:53 AM
Message Edited by VADave on 04-14-2009 06:54 AM
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 5 of 7
(4,695 Views)

Thanks for the help everyone!  With a little work on Excel.vi from VT92 I was able to get what I needed.

Jeremy Backer
CLAD
0 Kudos
Message 6 of 7
(4,682 Views)

JMBacker wrote:

I don't think your advice would be to open each sheet and run the macro if you had several hundred sheets to open from several hundred folders Smiley Happy.  Through LabVIEW I can automatically open every sheet from all the different folders.  One button and they all get changed.  Plus, I'll be doing this on a regular basis, so the easier the better.


Actually, I would!  You could open and run the macro on each one in about 5 seconds per file.  I could be done 100 in less then 5 minutes.  Nothing was said about several hundred folders, just several hundred sheets.  If I found that was too many too do, then I would program a loop in my Excel VB macro to handle them all which would only take another 10 minutes to program.

 

While I find LabVIEW is more fun to program with, if there is a better tool that makes more sense to use for a particular situation, such as using Excel to handle Excel spreadsheets, then I would use that.

 

 

 

 

Message Edited by Ravens Fan on 04-14-2009 08:58 AM
Message 7 of 7
(4,675 Views)