|
-
October 5th, 2009, 10:49 AM
#1
Excel - Referencing a named range
Hi folks, I'm tearing my hair out over this one and any help would be greatly appreciated.
I'm trying to reference a named range in my worksheet, but of the two methods that I've found, neither work.
If I use this:
dataRange = Program.application.Names.Application.Names("name of range").RefersToRange;
I receive the following error:
Non-invocable member 'Microsoft.Office.Interop.Excel._Application.Names' cannot be used like a method.
If I try to index it, as some have suggested, like this:
dataRange = Program.application.Names.Application.Names["name of range"].RefersToRange;
I recieve this error:
Cannot apply indexing with [] to an expression of type 'Microsoft.Office.Interop.Excel.Names'
Can anyone tell me what I'm doing wrong?
-
October 5th, 2009, 11:21 AM
#2
Re: Excel - Referencing a named range
I'm sorry, the line that I posed up there isn't the correct line. I was trying random garbage in my frustration.
Here are the two alternatives that I've tried:
dataRange = c_application.ActiveWorkbook.Names["name of range"].RefersToRange;
dataRange = c_application.ActiveWorkbook.Names("name of range").RefersToRange;
-
October 5th, 2009, 06:10 PM
#3
Re: Excel - Referencing a named range
Take a look at the Gembox.Spreadsheet Samples programme. You can download it from their site for free. It gives you some examples of how to do many things in Excel using C#. http://www.gemboxsoftware.com/
Its on this page http://www.gemboxsoftware.com/GBSpreadsheet.htm in the paragraph headed:
Features
(>) Launch the GemBox.Spreadsheet Sample Explorer
Download it and install it, very easy to use and view the code.
Last edited by rliq; October 5th, 2009 at 06:15 PM.
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|