HELP- Run-Time Error '91'

Discussion in 'AutoCAD' started by Aaron Cunningham, Mar 15, 2005.

  1. We have excel schedules that are linked to our drawings. If we don't open
    the excel file (first) that these schedules were created in we get bombarded
    with errors when we open up the drawing.

    Run-Time Error '91'
    Object Variable or With Block Variable not set

    any ideas on how to fix this problem? It is a real pain if you don't open
    the excel file first, because if you have 10 schedules linked in the drawing
    you will have to hit "End" or "Debug" 10 different times before the autocad
    drawing will open up.
     
    Aaron Cunningham, Mar 15, 2005
    #1
  2. Aaron,
    What method did you use to link the Excel data with in the beginning?
    Ken Hutson
    San Antonio, TX
     
    Kenneth Hutson, Mar 15, 2005
    #2
  3. In excel or AutoCad? In AutoCad we use the paste special method. In excel I
    really don't know. We have an engineer that deveolped a pretty complicated
    panel schedule worksheet. I probally can find out if you give me something
    to go on and then I can ask him.
     
    Aaron Cunningham, Mar 15, 2005
    #3
  4. So this object in AutoCAD is an OLE object? If so, I can't help you much as
    I avoid those. I did a copy from Excel and then a paste special in my
    AutoCAD. As Excel Spreadsheet. Closed Excel. Closed the drawing. Opened
    the drawing and didn't get an error 91. I suspect something may be amiss
    with your regristry.
    Cheers,
    Ken
     
    Kenneth Hutson, Mar 15, 2005
    #4
  5. Aaron Cunningham

    Oberer Guest

    Aaron, I think he's asking you how do you have these objects linked when he's asking about the "method" (ie the programming function used to link your excel data to your autocad object(s))
     
    Oberer, Mar 15, 2005
    #5
  6. Yes these are OlE objects. I believe that the problem lies within the excel
    schedules themselves as we have alot of VBA in them to different calcs,etc.
    Occasionaly we have a drawing that will have an excel schedule that doesn't
    have any VBA programming in it and they open up just fine, like you
    encountered.
     
    Aaron Cunningham, Mar 15, 2005
    #6
  7. By the way this happens on every computer in the company.
     
    Aaron Cunningham, Mar 15, 2005
    #7
  8. If I try to Debug it says "Out of Memory"

     
    Aaron Cunningham, Mar 15, 2005
    #8
  9. Aaron,
    Try this.. Start Excel and open a workbook that contains suspected bad code.
    Go to the VBA code window. Tools.. Macro.. Visual Basic Editor. Run every
    macro you can until you find the one with bad code. You can also step
    through code line by line using the F8 key. Perhaps an unclosed While
    statement...
    Kenneth
     
    Kenneth Hutson, Mar 15, 2005
    #9
  10. Also, once in the VBA IDE in Excel, you can use the menu Debug...Compile to
    see where any errors are.

    g/l
     
    James Belshan, Mar 15, 2005
    #10
  11. I know nothing about VBA but I sat down with the engineer and we took this
    line out of one of our macros. Seems to work alright now. Both of us don't
    know why this seems to be the problem but this is what we did-

    Sub Auto_Open()
    AddMenuItems
    'UpdateSheetReferences
    Range("C1").Select
    End Sub

    By taking out the UpdateSheetReferences we no longer recive those error
    messages. Does this make any sense to you guys.
     
    Aaron Cunningham, Mar 15, 2005
    #11
  12. Yes we commented it out. If we don't this is when all of the errors
    reappear.
     
    Aaron Cunningham, Mar 15, 2005
    #12
  13. Aaron.,

    A sub named Auto_Open runs when Excel starts. AddMenuItems could be a call
    to anothe sub (apparently to customize your menu appearance). Looks like a
    method without an object qualifier. Search on Microsoft did not reveal any
    VBA context reference to the term. UpdateSheetReferences appears to be
    commented out. Perhaps a call to another sub. Range("C1").Select selects
    the cell at reference C1.

    So does everything work on the Acad side now?
    Kenneth
     
    Kenneth Hutson, Mar 15, 2005
    #13
  14. And yes so far AutoCad works fine.

    Now we aren't sure if removing that line is going to effect anything down
    stream of what we took out. So far it doesn't appear to affect any of the
    macros within our spreadsheet.
     
    Aaron Cunningham, Mar 15, 2005
    #14
  15. Glad it's working.
    In the VBA IDE search the entire project for "UpdateSheetReferences". It's
    probably a sub. And that sub could call other subs. If you find it, and
    follow the code execution, chances are good that the erroneous code can be
    found and debugged. Then you could perhaps re-enable your commented line of
    code. Good Luck.
    Kenneth
     
    Kenneth Hutson, Mar 15, 2005
    #15
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.