Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to read external workbook


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

--
smilysof
-----------------------------------------------------------------------
smilysoft's Profile: http://www.excelforum.com/member.php...fo&userid=3270
View this thread: http://www.excelforum.com/showthread.php?threadid=52529

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Need to read external workbook

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/arch...ing-workbooks/

--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com

smilysoft wrote:
Hi,

I am right now working Excel using VBA. I am using DAO for reading an
external sheet data. I am not getting the output. Can some one help
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 named
'Instruction' from an external workbook file. Could you please let me
know the exact syntax for accessing the sheet information using DAO.
And also how to refer column header in the 'SELECT' query if the
column names have words separated by space. For example "Project
Name" is the column header name separated by space. And any good DAO
using VBA link will also help me.

Thanks in advance!

Ravo



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 to read external cell? mattsvai[_16_] Excel Programming 3 February 7th 06 02:45 AM
Search and read registry for particular external application KS Wong[_2_] Excel Programming 1 December 11th 05 07:53 PM
How to read active Excel celll value by external vb application? Jack Excel Programming 2 February 11th 04 09:06 PM
Excel Gurus = want a macro in 1 workbook to get info from another workbook = Read please harry Excel Programming 5 December 20th 03 03:26 AM
Read variables from external file Daniel Köster Excel Programming 2 October 2nd 03 07:55 AM


All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"