473,503 Members | 3,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Microsoft.Office.Interop.Excel.Worksheet & Named Fields

1 New Member
I want to be able to get a list of all custom named fields in an Excel worksheet, but I am having trouble with this. In the code below, access to a field that I named "DEALCODE" works fine - I get the value. When I try to get a collection of named cells in the loop below, I come up with only one entry: 'Portfolio Company Information'!Print_Area

The part before the ! is obviously my sheet name, but I have a whole slew of custom named cells in the sheet and I want to get a list. What am I doing wrong here? Thanks in advance!

Code snippet:

Workbook currentCompanyFile = xlApp.Workbooks.Open(current_fileNameDir, false, true, 5, "", "", true, XlPlatform.xlWindows, "", true, false, 0, true, true, false);

Sheets allSheetsInCurrentBook = currentCompanyFile.Worksheets;

Microsoft.Office.Interop.Excel.Worksheet first_sheet = (Microsoft.Office.Interop.Excel.Worksheet)allSheet sInCurrentBook.get_Item(wsName_1);

//this works, gets the value of a named field called 'DEALCODE'
xlApp.Goto("DEALCODE", false);
deal_code = xlApp.ActiveCell.FormulaR1C1.ToString();

//i want this to return all the named fields, including 'DEALCODE', but
//it returns only 'Print_Area'
foreach (Name this_name in first_sheet.Names)
{
Console.WriteLine(this_name.Name.ToString());
}
Dec 27 '07 #1
0 3711

Sign in to post your reply or Sign up for a free account.

Similar topics

0
5521
by: AllenF | last post by:
I have a library (named DSG) created in C# which other programs use to build Excel spreadsheeets. This library uses the office PIAs "Microsoft.Office.Interop.Excel.dll" and also references the...
0
953
by: Henry | last post by:
I am trying to build .NET Windows form application to manipulate data is specified Excel spreadsheets, but I am running short on information and my searches of MSDN aren't finding the data I need....
6
1961
by: ©pEIO | last post by:
I have installed the PIA of Microsoft Office 2003 and the installation was succefully. If I add the reference of Microsoft Excel 11.0, I see that the property CopyLocal is False and the assembly...
3
10775
by: ©pEIO | last post by:
Example: Dim xlsExcel As Excel.Application Dim wkbExcel As Excel.Workbook Dim wksExcel As Excel.Worksheet xlsExcel = New Excel.Application wkbExcel = xlsExcel.Workbooks.Open("C:\Test.xls")...
2
11436
by: William LaMartin | last post by:
I have created a program that allows for the automation of things in Word documents, like changing the values of DocVariables and the links to Excel Sheets. I did it using interoperoperatability,...
5
49760
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. ...
2
2323
by: bbasberg | last post by:
I have been working hard to clean up my code but I am still wondering why all incoming records go to the "AddNew" part of the IF statement and never to the Edit alternative. I believe that it must be...
1
8694
by: baling | last post by:
Hi.... Hi everybody, i have a code that i make in VBA and know I want to use this code in to VB6. But i don't know how to use that code in to VB 6.0 Please correct this code so i can use it in VB...
10
4970
KodeKrazy
by: KodeKrazy | last post by:
I'm trying to read an Excel worksheet and do a find/replace for all of the commas "," in any of the cells in the sheet and replace them with a dash "-" I can get as far as getting the workbook...
0
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.