TransferSpreadSheet Method From AutoCAD?

Discussion in 'AutoCAD' started by Oberer, Oct 13, 2004.

  1. Oberer

    Oberer Guest

    I'm writing data to a table which I'd like to export to excel for distribution.

    The "transferspreadsheet" method doesn't seem to like being called outside the DB.
    (ERROR: 2075: operation requires and open database)

    Can anyone help me with this?

    I grabbed this code from the board, then tried to figure out what the error 2075. i added the access app object hoping that'd fix it....

    TIA!!

    Private Sub cmdLateralViewReport_Click()


    Dim xlsApp As Excel.Application
    Dim wBook As Excel.Workbook
    Dim strFileName As String
    Dim oDB As Database

    Dim accessApp As Access.Application

    strFileName = "c:\new test.xls"

    Set oDB = getDB
    Set accessApp = CreateObject("Access.Application")
    With accessApp
    .Visible = True
    End With
    accessApp.DoCmd.TransferSpreadsheet acExport, 8, "qryLateralCheck", strFileName, True, ""
    ' create spreadsheet

    'DoCmd.TransferSpreadsheet acExport, 8, "qryLateralCheck", strFileName, True, ""

    Set accessApp = Nothing
    Set oDB = Nothing

    ' open it
    Set xlsApp = CreateObject("Excel.Application")
    'you can use GetObject() first to open .xls in a
    'already opend Execl session, and use error trap
    'to handle it if no Excel session is currently
    'open, then use CreateObject() to create a new Excel
    'session.
    'If you do not mind to always open a new Excel session
    'you can simply:
    ' Set xlsApp=New Excel.Application

    With xlsApp
    Visible = True
    WindowState = xlNormal '(or xlMinimized, xlMaximized)
    Set wBook = .Workbooks.Open(strFileName)
    End With

    'Do whateveryou want to the spead sheet (WorkBook)
    'You can get data from the work sheet to your drawing.
    'Or you can get your data from drawing and send them to
    'Excel work sheet

    'wBook.Close True
    'xlsApp.Quit

    Set wBook = Nothing
    Set xlsApp = Nothing

    End Sub
     
    Oberer, Oct 13, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.