Re: Select from first work*** without knowing it's name
From: Roger Twomey (rogerdev_at_vnet.on.ca)
Date: 05/03/04
- Next message: YingYang: "Re: Using an Activex DLL to apply formulas in Excel"
- Previous message: David McRitchie: "Re: Remove Hard Return"
- In reply to: Don Guillett: "Re: Select from first work*** without knowing it's name"
- Next in thread: onedaywhen: "Re: Select from first work*** without knowing it's name"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 3 May 2004 15:12:50 -0400
No Luck.
Here are the various things I have tried:
I tried this:
strExcelSQL = "Select * from [Sheets(1)]"
Which Resulted in this:
The Microsoft Jet database engine could not find the object 'Sheets[1]'. Make sure the object exists and that you spell its name and the path name correctly.
--**
strExcelSQL = "Select * from [Sheets(1).Active]"
Which Resulted in this:
The Microsoft Jet database engine could not find the object 'Sheets[1].Active'. Make sure the object exists and that you spell its name and the path name correctly.
--**
strExcelSQL = "Select * from [Sheets(1).Activate]"
Which Resulted in this:
The Microsoft Jet database engine could not find the object 'Sheets[1].Activate'. Make sure the object exists and that you spell its name and the path name correctly.
--**
strExcelSQL = "Select * from Sheets(1).Activate"
Which Results in this:
Syntax error in FROM clause.
--**
strExcelSQL = "Select * from Sheets(1).Active"
Which results in this:
Syntax error in FROM clause.
--**
"Don Guillett" <donaldb@281.com> wrote in message news:OtvlS0TMEHA.3420@TK2MSFTNGP11.phx.gbl...
> try
>
> Sheets(1).Activate
>
> --
> Don Guillett
> SalesAid Software
> donaldb@281.com
> "Roger Twomey" <rogerdev@vnet.on.ca> wrote in message
> news:eie3BbTMEHA.1156@TK2MSFTNGP09.phx.gbl...
> > I have an app that reads excel spreadsheets. It works fine, as long as the
> > first sheet is called "Sheet1". If there is no sheet called Sheet1 it
> > crashes.
> >
> > I don't want to force the user to change the spread***, I want to read
> the
> > first page no matter what it is called.
> >
> > Here is how my code works right now:
> >
> > <code>
> >
> > Dim myds As New DataSet
> > Dim MyExcelConnectStr As String =
> "Provider=Microsoft.Jet.OLEDb.4.0;data
> > source=" & strFileName & ";Extended Properties=""Excel
> 8.0;HDR=No;IMEX=1"""
> >
> > strExcelSQL = "SELECT * FROM [Sheet1$]"
> >
> > Dim MyOleADapter As New OleDb.OleDbDataAdapter(strExcelSQL,
> > MyExcelConnectStr)
> >
> > MyOleADapter.Fill(myds, "xlsdata")
> >
> > intRows = myds.Tables(0).Rows.Count
> >
> > intFields = myds.Tables(0).Columns.Count
> >
> > </code>
> >
> > Is there some function or code that can be used in place of:
> >
> > strExcelSQL = "SELECT * FROM [Sheet1$]"
> >
> > which will provide the same function (open sheet1) without knowing it's
> > name? (which may not be Sheet1). Or, a way to GET the first sheets name
> > (vb.net)?
> >
> > Thanks.
> >
> >
> >
>
>
- Next message: YingYang: "Re: Using an Activex DLL to apply formulas in Excel"
- Previous message: David McRitchie: "Re: Remove Hard Return"
- In reply to: Don Guillett: "Re: Select from first work*** without knowing it's name"
- Next in thread: onedaywhen: "Re: Select from first work*** without knowing it's name"
- Messages sorted by: [ date ] [ thread ]