More Processing Multiple Drawings via VBA

Discussion in 'AutoCAD' started by BML, Jul 24, 2003.

  1. BML

    BML Guest

    I'm trying to write some VBA code that will make certain modifications to a set of drawings. One of the first tasks is to read in the list of all layers in the drawing and cycle through a for-next loop to modify the layers. It works for the first pass, but when I switch to the second drawing, I get a fatal error unhandled access violation exception when I try to cycle through the layers of the second drawing. I thought that maybe it was because I was using the same variable to represent the current layer and set of all layers, but indexing did not help. Any thoughts?

    Thanks!
     
    BML, Jul 24, 2003
    #1
  2. BML

    BML Guest

    I think I've got that part correct. I put in some message boxes to show me what document is active, how many total documents are open, etc. Those all work fine. The only problem is when I start to cycle through the layers. I've stepped through the code and it always hangs on the same line.

    As an example:

    For Each CurrDwg in AllDwgs 'works okay
    CurrDwg.Activate 'works okay
    MsgBox CurrDwg.Name 'works okay
    MsgBox AllDwgs.Count 'works okay

    For Each CurrLayer in AllLayers 'causes the fatal error
     
    BML, Jul 24, 2003
    #2
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.