Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ADO and sheet name with spaces

I am having problems with retreiving data from a worksheet where its name
contains spaces.

SELECT * FROM [<SourceSheet$A1:H100];

When <SourceSheet is "My Sheet", I get the message "The Microsoft Jet
database engine could not find the object...". I modified source sheet to
look like 'My Sheet', but that didn't work either.

What is the proper syntax for a source sheet containing spaces?

M
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default ADO and sheet name with spaces

This works for me:

szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Sales.xls;" & _
"Extended Properties=Excel 8.0;"
szSQL = "SELECT * FROM [My Sheet$A1:E10]"

Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText

--
Jim Rech
Excel MVP
"mwaller" wrote in message
...
|I am having problems with retreiving data from a worksheet where its name
| contains spaces.
|
| SELECT * FROM [<SourceSheet$A1:H100];
|
| When <SourceSheet is "My Sheet", I get the message "The Microsoft Jet
| database engine could not find the object...". I modified source sheet to
| look like 'My Sheet', but that didn't work either.
|
| What is the proper syntax for a source sheet containing spaces?
|
| M


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default ADO and sheet name with spaces

"Jim Rech" wrote ...

I am having problems with retreiving data from a worksheet where its name
contains spaces.

SELECT * FROM [<SourceSheet$A1:H100];

When <SourceSheet is "My Sheet", I get the message "The Microsoft Jet
database engine could not find the object..."


This works for me:

szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Sales.xls;" & _
"Extended Properties=Excel 8.0;"
szSQL = "SELECT * FROM [My Sheet$A1:E10]"

Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText


I'm wondering if the OP has a Chr$(36) or a Chr$(39) character in the
sheet name. They really make things tricky <g.

Jamie.

--
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ADO and sheet name with spaces

The only difference that I can see is that my connect string has the
following in the extended properties: ;HDR=NO;IMEX=1'. The sql looks just
like yours.

Looks like I'll have to keep digging.

Mike

"Jim Rech" wrote:

This works for me:

szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Sales.xls;" & _
"Extended Properties=Excel 8.0;"
szSQL = "SELECT * FROM [My Sheet$A1:E10]"

Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText

--
Jim Rech
Excel MVP
"mwaller" wrote in message
...
|I am having problems with retreiving data from a worksheet where its name
| contains spaces.
|
| SELECT * FROM [<SourceSheet$A1:H100];
|
| When <SourceSheet is "My Sheet", I get the message "The Microsoft Jet
| database engine could not find the object...". I modified source sheet to
| look like 'My Sheet', but that didn't work either.
|
| What is the proper syntax for a source sheet containing spaces?
|
| M



Reply
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
how can I find cell/s in excel sheet having blank spaces more tha. Excel blank cells with spaces Excel Discussion (Misc queries) 1 August 25th 08 12:54 PM
formula to bring value from another sheet with different spaces veena Excel Discussion (Misc queries) 6 July 11th 08 12:25 AM
how do I remove leading spaces and leave the remianing spaces w Debi Excel Worksheet Functions 6 February 28th 07 03:29 PM
spaces not recognized as spaces windsurferLA Excel Worksheet Functions 9 July 27th 06 11:49 AM
Spaces in sheet names Minilek Excel Programming 2 July 13th 04 07:11 AM


All times are GMT +1. The time now is 11:22 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"