Accessing an Excel file without opening Excel 
Author Message
 Accessing an Excel file without opening Excel

I'm trying to access an Excel 7.0 spreadsheet through my app in VB 6.0
without actually opening Excel.  (I've added the Microsoft Excel 5.0
Object Library in my Project-References section...I'm assuming that's
the right library to add since the only other library for Excel in VB is
Office 97 - which my users don't use.) First of all, is this possible?

Second of all, I tried this code out and get an error at the line where
I reference the Workbook object saying "Workbooks method of Application
class failed"...

Dim objList As Object
Dim wkbList As Worksheet
Dim nRows As Integer
Dim arrListValues() As String
Dim i As Integer

Set objList = CreateObject("Excel.Application")
Set wkbList = objList.Workbooks(txtListFile).Sheets("Sheet1")
nRows = wkbList.Rows.Count
ReDim Preserve arrListValues(1 To nRows)

For i = 1 To nRows
    ' Fill the array with the values from column A of the worksheet.
    arrListValues(i) = wkbList.Range("A" & i + 1).Value
Next i

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 08 Apr 2002 03:00:00 GMT  
 Accessing an Excel file without opening Excel
1)You should insert Microsoft Excel 8.0 Object Library
2)You can create a workbook outside the program then access the workbook
using the VB program.
3)Use the getobject("XXX.xls") method to link the workbooks to the program.
Quote:

>I'm trying to access an Excel 7.0 spreadsheet through my app in VB 6.0
>without actually opening Excel.  (I've added the Microsoft Excel 5.0
>Object Library in my Project-References section...I'm assuming that's
>the right library to add since the only other library for Excel in VB is
>Office 97 - which my users don't use.) First of all, is this possible?

>Second of all, I tried this code out and get an error at the line where
>I reference the Workbook object saying "Workbooks method of Application
>class failed"...

>Dim objList As Object
>Dim wkbList As Worksheet
>Dim nRows As Integer
>Dim arrListValues() As String
>Dim i As Integer

>Set objList = CreateObject("Excel.Application")
>Set wkbList = objList.Workbooks(txtListFile).Sheets("Sheet1")
>nRows = wkbList.Rows.Count
>ReDim Preserve arrListValues(1 To nRows)

>For i = 1 To nRows
>    ' Fill the array with the values from column A of the worksheet.
>    arrListValues(i) = wkbList.Range("A" & i + 1).Value
>Next i

>Sent via Deja.com http://www.deja.com/
>Before you buy.



Tue, 09 Apr 2002 03:00:00 GMT  
 Accessing an Excel file without opening Excel
Hi Kerri,

You always need to start Excel, but if you want to you can make sure
that the user doesn't see it like this:

Dim X As Object

        Set X=CreateObject(,"Excel.Application")
        X.Visible=False

About adding the reference:

The wqay you have coded (CreateObject) you don't need this reference.
Personally (I work a lot with Office 97 and VB 6) I never use these
references, but I always work with createObject.

The can prevend the error you get by using this code (I think):

Dim X As Object
Dim Ws as Object

        Set X=CreateObject(,"Excel.Application")
        X.Visible=False
        set WS=X.Workbookes("Filename").Sheets("SheetName")

This should work fine in Office 97. I'm not sure about the
Object-structure of Office 7.0.

Gerard

Quote:

>I'm trying to access an Excel 7.0 spreadsheet through my app in VB 6.0
>without actually opening Excel.  (I've added the Microsoft Excel 5.0
>Object Library in my Project-References section...I'm assuming that's
>the right library to add since the only other library for Excel in VB is
>Office 97 - which my users don't use.) First of all, is this possible?

>Second of all, I tried this code out and get an error at the line where
>I reference the Workbook object saying "Workbooks method of Application
>class failed"...

>Dim objList As Object
>Dim wkbList As Worksheet
>Dim nRows As Integer
>Dim arrListValues() As String
>Dim i As Integer

>Set objList = CreateObject("Excel.Application")
>Set wkbList = objList.Workbooks(txtListFile).Sheets("Sheet1")
>nRows = wkbList.Rows.Count
>ReDim Preserve arrListValues(1 To nRows)

>For i = 1 To nRows
>    ' Fill the array with the values from column A of the worksheet.
>    arrListValues(i) = wkbList.Range("A" & i + 1).Value
>Next i

>Sent via Deja.com http://www.deja.com/
>Before you buy.



Tue, 09 Apr 2002 03:00:00 GMT  
 Accessing an Excel file without opening Excel
I don't believe you can automate Excel without having Excel running.
However, you can use ODBC to read in a spreadsheet and operate on the data
in a Resultset using RDO. I would assume you could also use ADO to get a
Recordset, but I haven't done that yet.
HTH
--
Gary, MCT, MCP, MCSD
home site http://www.enter.net/~garyl


Quote:
> I'm trying to access an Excel 7.0 spreadsheet through my app in VB 6.0
> without actually opening Excel.  (I've added the Microsoft Excel 5.0
> Object Library in my Project-References section...I'm assuming that's
> the right library to add since the only other library for Excel in VB is
> Office 97 - which my users don't use.) First of all, is this possible?

> Second of all, I tried this code out and get an error at the line where
> I reference the Workbook object saying "Workbooks method of Application
> class failed"...

> Dim objList As Object
> Dim wkbList As Worksheet
> Dim nRows As Integer
> Dim arrListValues() As String
> Dim i As Integer

> Set objList = CreateObject("Excel.Application")
> Set wkbList = objList.Workbooks(txtListFile).Sheets("Sheet1")
> nRows = wkbList.Rows.Count
> ReDim Preserve arrListValues(1 To nRows)

> For i = 1 To nRows
>     ' Fill the array with the values from column A of the worksheet.
>     arrListValues(i) = wkbList.Range("A" & i + 1).Value
> Next i

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 10 Apr 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Reading Excel files without opening excel

2. Excel - VBA - Retreive file without opening them in Excel

3. Opening an excel file through a form/running excel macros through access

4. How can I open Excel workbook without using Excel.Worksheet

5. Saving an Excel file without using Excel

6. Saving an Excel file without using Excel

7. Write a Excel File Without Excel App

8. Using an Excel file without having Microsoft Excel installed

9. Creating Excel Files Without Excel...

10. Viewing Excel files without firing up Excel.

11. Write to an Excel file from VB without Excel present

12. read excel file in access 2000 lire fichier excel dans access 2000

 

 
Powered by phpBB® Forum Software