VB5 using OLE Automation on MS Access database -- Help 
Author Message
 VB5 using OLE Automation on MS Access database -- Help

The users of a Visual Basic app I worked on would like to be able to
print output from a query to an Excel spreadsheet.  Having programmed in
MS Access quite a lot, I thought sure, DoCmd.TransferSpreasheet, no
problem.  Well, I forgot VB doesn't have that built-in, so I'm trying to
do it by automating the Access database to run the transfer spreadsheet.

Here is my test code inside a button's click event:

Private Sub Command1_Click()

Dim obj as Object

    Set obj = GetObject("C:\test.mdb")
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"List-Reports", "test.xls", True
    obj.Application.Quit
    Set obj = Nothing

End Sub

Now, the code runs fine the first time, but any call thereafter causes
the error:
    Run time error '-2147023174 (800706ba)':
        Automation Error

I'm just impressed that it actually could tell where to look to find the
query List-Reports (figured I'd have to do something like:
obj.DoCmd.TransferSpreadsheet .......)

Any suggestions on what else I might need to do?  Am I not cleaning up
things completely?  Is there a better way to do this?  etc...



Sun, 12 Nov 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. VB5 OLE Automation: MS Access Data into Excel

2. How do I start an access database (mdb) from VB4 using OLE automation

3. How do I start an access database (mdb) from VB4 using OLE automation

4. Regarding Accessing External database using MS-Access and MS-Visual Basic

5. MS Graph 5 OLE Automation in Word from Access 97

6. ASK for help VB5:IS POSIBLE SHOW PICTURE(JPEG FORMAT) FROM DATABASE(ACCESS)/ OLE object

7. OLE Automation using Excel 5.0 and VB5/6

8. VB5 automation OLE-open Access and named file

9. Accessing a database opened through OLE Automation

10. Sending text to Word 97 from Access 97 using OLE automation

11. Using OLE Automation in Access 2.0

12. Using DialUpNetworking and OLE Automation to automate Access Replication

 

 
Powered by phpBB® Forum Software