Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Need to read external workbook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
smilysoft - 22 Mar 2006 16:27 GMT
Hi,

I am right now working Excel using VBA.  I am using DAO for reading a
external sheet data.  I am not getting the output.  Can some one hel
me in fixing this problem.  Following is the code snapshot:

Set rs = db.OpenRecordset("SELECT * from Instruction")
If rs Is Nothing Then
MsgBox "Can't open the file!", vbExclamation
ThisWorkbook.Name
db.Close
Set db = Nothing
Exit Sub
End If

Here 'rs' is returning null.  I am trying to open a work sheet name
'Instruction' from an external workbook file.  Could you please let m
know the exact syntax for accessing the sheet information using DAO.
And also how to refer column header in the 'SELECT' query if the colum
names have words separated by space.  For example "Project Name" is th
column header name separated by space.  And any good DAO using VBA lin
will also help me.  

Thanks in advance!

Rav
Dick Kusleika - 22 Mar 2006 23:52 GMT
Ravo

I think you need the sheet name in brackets and append a dollar sign, like

SELECT * From [Instruction$]

I think you can put single quotes around the field names if they have
spaces, but I haven't tested it.

SELECT 'Project Name' From [Instructions$]

There's an example of using ADO, but not with as much detail as you'd like,
here

http://www.dailydoseofexcel.com/archives/2006/01/24/different-approaches-to-retr
ieve-data-from-underlying-workbooks/


Signature

Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com

> Hi,
>
[quoted text clipped - 22 lines]
>
> Ravo
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.