problems when opening Excel from ACAD

Discussion in 'AutoCAD' started by mtechserv, Jan 25, 2005.

  1. mtechserv

    mtechserv Guest

    I've written an AutoCAD VBA program that is activated from a toolbar button in ACAD. It retrieves info. from the drawing, then opens Excel and writes the drawing info to Excel. The program works fine the first time I use it. Then I close Excel, and try to run the program from AutoCAD again, but it crashes after Excel opens, but before it writes the data to the spreadsheet.
    In order to run the program again without crashing, I need to go into the VBA editor, and reset the program. It wil then work fine one time, then crashes again the second time until I reset everything.
    It appears as though it doesn't release the ActiveSheet member. How do I fix this?
     
    mtechserv, Jan 25, 2005
    #1
  2. mtechserv

    user0 Guest

    You've got to make sure you've Closed/Released/Set = Nothing, all that stuff, for each Excel object you've referenced in your code.
     
    user0, Jan 25, 2005
    #2
  3. mtechserv

    Norman Yuan Guest

    Besides the other posts, you may consider using ADO/DAO to access data in
    *.xls file (read/write). It is faster than automating Excel. You do not even
    need to have Excel installed.

    button in ACAD. It retrieves info. from the drawing, then opens Excel and
    writes the drawing info to Excel. The program works fine the first time I
    use it. Then I close Excel, and try to run the program from AutoCAD again,
    but it crashes after Excel opens, but before it writes the data to the
    spreadsheet.
    VBA editor, and reset the program. It wil then work fine one time, then
    crashes again the second time until I reset everything.
    fix this?
     
    Norman Yuan, Jan 25, 2005
    #3
  4. More than that, they have to be done in the exact reverse order you used to
    create them --- cells/ranges/worksheet/workbook/object

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Jan 25, 2005
    #4
  5. mtechserv

    user0 Guest

    Yeah, I figured that to be a given. But still a good idea to mention it.
     
    user0, Feb 22, 2005
    #5
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.