LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Retrieving the values of Excel check boxes in .NET

I have an Excel spreadsheet which contains multiple un-grouped check boxes
(from the Forms toolbar) which are not linked to any particular cell(s). I
want to read their values in .NET code. For this I'm using 'Microsoft Office
Interop Excel' and 'Microsoft Vbe Interop Forms' libraries. This is the code
I'm using:

String excelFile = "C:\\FileName.xls";
Excel.Application estimate = new Excel.Application();
Excel.Worksheet workSheet = new Excel.Worksheet();
estimate.Workbooks.Open(excelFile, 0, true, 5, "", "", false,
Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
workSheet =
(Excel.Worksheet)estimate.Worksheets.get_Item("Wor ksheetName");
Excel.CheckBox cb =
(Excel.CheckBox)workSheet.Shapes.Item("CheckBoxNam e").OLEFormat.Object;

cb.Value returns the value of the check box (the value is -4146 if the check
box is unchecked, 1 if it is checked and null if it is mixed).

At some point in time I was able to see the names of all the check boxes in
my worksheet (they were named "Check Box 1", "Check Box 2" and so on). But
now I see that all the check boxes have the same name "CheckBox" which is
very strange. This is making it impossible for me to retrieve the values of
the check boxes by specifying the check box name. I know I can use the index
also but it poses a similar problem - 'how do I know the index of each check
box?'. Coming back to the name issue, is there any way I can see the unique
names of all my check boxes again? Is there any mode which I have to use to
be able to see the unique names? What am I missing here?

Any help would be greatly appreciated. Thanks in advance.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Boxes In Excel frpkaren Excel Discussion (Misc queries) 2 March 28th 07 09:18 AM
Check Boxes In Excel bigwheel Excel Discussion (Misc queries) 0 March 28th 07 12:19 AM
Help with Comparing values and retrieving values in Excel!!!!!! [email protected] Excel Worksheet Functions 1 November 17th 06 12:21 AM
How do i set up check boxes in excel? Mountaintop Ryan New Users to Excel 1 August 17th 06 11:59 PM
Using Check boxes in Excel Louise Excel Worksheet Functions 4 April 4th 06 02:32 PM


All times are GMT +1. The time now is 08:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"