ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using ADODB to read data out of another excel file (https://www.excelbanter.com/excel-programming/285165-using-adodb-read-data-out-another-excel-file.html)

Chris Edwards

Using ADODB to read data out of another excel file
 
I am using ADODB to read data out of another excel file.
Sometime the line "oConn.Open XLFile" actually causes
excel to "OPEN" the referenced document - when it is
soposed to just open it as a data source.
I am using the microsoft example source code (see below)
for doing this. This issue is not consistantly re-
produceable.

Any Ideas?

-Chris
(code follows)

Dim XLFile As String
XLFile = "\\fls02\apps\available Packages.xls"
Dim oConn As New ADODB.Connection
oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel
8.0;ReadOnly=True;FirstRowHasNames=False;HDR=NO"
oConn.Open XLFile



onedaywhen

Using ADODB to read data out of another excel file
 
If the connection remains open the workbook will be locked and can't
be opened, so ensure you are closing your connection with oConn.Close.
Is this the behavior you are getting or is the workbook opening
'visibly'?

--

"Chris Edwards" wrote in message ...
I am using ADODB to read data out of another excel file.
Sometime the line "oConn.Open XLFile" actually causes
excel to "OPEN" the referenced document - when it is
soposed to just open it as a data source.
I am using the microsoft example source code (see below)
for doing this. This issue is not consistantly re-
produceable.

Any Ideas?

-Chris
(code follows)

Dim XLFile As String
XLFile = "\\fls02\apps\available Packages.xls"
Dim oConn As New ADODB.Connection
oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel
8.0;ReadOnly=True;FirstRowHasNames=False;HDR=NO"
oConn.Open XLFile


Chris

Using ADODB to read data out of another excel file
 
I do close the connection when I am done using it.
The workbook opens "visibly"(and I have it isolated to
that one individual line).. Which confuses me as it is a
declared object (Dim oConn As New ADODB.Connection) and
should in no way open the file..

-Chris

-----Original Message-----
If the connection remains open the workbook will be

locked and can't
be opened, so ensure you are closing your connection with

oConn.Close.
Is this the behavior you are getting or is the workbook

opening
'visibly'?

--

"Chris Edwards"

wrote in message news:<017101c3c004$a0c7b2b0
...
I am using ADODB to read data out of another excel

file.
Sometime the line "oConn.Open XLFile" actually causes
excel to "OPEN" the referenced document - when it is
soposed to just open it as a data source.
I am using the microsoft example source code (see

below)
for doing this. This issue is not consistantly re-
produceable.

Any Ideas?

-Chris
(code follows)

Dim XLFile As String
XLFile = "\\fls02\apps\available Packages.xls"
Dim oConn As New ADODB.Connection
oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel
8.0;ReadOnly=True;FirstRowHasNames=False;HDR=NO"
oConn.Open XLFile

.



All times are GMT +1. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com