Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO/Excel question

Status
Not open for further replies.

dds82

Programmer
Jun 5, 2002
251
US
I'm using ADO objects to query an Excel spreadsheet. As part of this project, I need to get a list of all the column names except the first in a certain sheet. I do that by executing a "Select * from [the_worksheet$]" and the following code:

Code:
Set rs=myConn.Execute("Select * from [the_worksheet$]")

For x=1 to rs.Fields.Count
    Response.Write(rs(x).Name)
Next x

The "Select" statement works fine, but I've noticed the following weird behavior:

The worksheet has three columns with header rows; let's name them col1, col2, and col3. I expect this code to only output "col2" and "col3", which it does when I have the worksheet open in Excel at the same time. However, when I don't, it outputs "col2", "col3", "F4", "F5", "F6", "F7".

Does anybody know where the extra columns came from?

Thanks.
 
There's no VB code in the sheet, if that's what you're asking. I'm not really sure what you mean.
 
I just didn't know if you were using this as a database or if you were access the data in a worksheet using VBA for something else.

I have never accessed an Excel sheet out of Excel, but I do a lot of VBA and cells so I though that maybe I could help, but it doesn't look like it.

-Uncle Cake
 
does setting the Print Area around only the wanted cells/columns help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top