LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
John Brock
 
Posts: n/a
Default How do I find all named ranges in VB.NET?

I am using VB.NET to read Excel workbooks which have various named
ranges, some of which may not exist in any given workbook. I am
trying to get a list of all the range names -- otherwise I need to
use a Try block to avoid throwing an exception when I try to read
data from ranges which aren't there, and this slows things down
considerably.

I am able to find the *number* of named ranges in a particular
workbook using this expression:

xlApp.ActiveWorkbook.Names.Count

(where xlApp is my open Excel application handle, typed as
Microsoft.Office.Interop.Excel.Application). And knowing the names
I can retrieve the ranges themselves using:

xlApp.ActiveWorkbook.Names.Item("MyRangeName").Ref ersToRange

But try as I might I can't seem to figure out how to get a list of
the actual names! I tried giving the Item property an integer
index, but that throws an exception. Can anyone give me a clue?

(I'd also like to get a list of styles in the workbook, and I
suspect this is the same problem, since I can get the number of
styles defined using xlApp.ActiveWorkbook.Styles.Count).
--
John Brock


 
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
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
Macro (Print) - Calling Named Ranges KGlennC Excel Discussion (Misc queries) 1 March 19th 05 09:20 PM
Named Ranges Donna Excel Discussion (Misc queries) 3 February 1st 05 11:35 PM
Poor Workbook Performance due to Named Ranges jrusso Excel Discussion (Misc queries) 2 January 10th 05 11:39 PM
Named dynamic ranges, copied worksheets and graph source data WP Charts and Charting in Excel 1 November 28th 04 05:19 PM


All times are GMT +1. The time now is 06:51 AM.

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

About Us

"It's about Microsoft Excel"