×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Modifying Multiple Drawings via VBA

Modifying Multiple Drawings via VBA

Modifying Multiple Drawings via VBA

(OP)
I'm trying to write some code that will make certain modifications to a set of drawings.  One of the first tasks is to get the list of all layers on the active drawing, then cycle through each using a for-next loop to modify those layers (turn off, rename, etc.).  This works okay for the first drawing I process.  I then continue on with some other changes, save and close the active drawing.  Then when I switch to the next drawing and make it active, I try to read in the new layer names and run the for-next loop again.  On the second pass through I get a fatal error unhandled access violation exception.  I thought it might have been caused by using the same variable to represent the current and set of all layers, but indexing the variables did not help.  Any thoughts?

Thanks!

RE: Modifying Multiple Drawings via VBA

Make sure your variables are not globals. Local variables will get set to nothing when the function or sub is done running. Like you said, you may have assigned a object to a variable that loses its reference when you close the file and start on the next one.

"Whether you think that you can, or that you can't, you are usually right "
.. Henry Ford

RE: Modifying Multiple Drawings via VBA

(OP)
I don't have any global declarations in this file.  I know that I can read what the current document is, as I put in some message boxes and stepped through the code.  I can cycle to the beginning of the 2nd For-Next loop, activate the next drawing, count the number of total drawings open, and display a message box that shows these values.  But when I start the For-Next loop to go through the layers, it always hangs up.

Thanks!

RE: Modifying Multiple Drawings via VBA

Not seeing the code, I will try a few tips:
-Purge the drawing before processing it.
-Make sure layers are not locked or frozen (something that might make it trip)
-Set the variable that seems to catch on to nothing before exiting the routine
-Make sure the layer is not an xref layer

A beginning place..

"Whether you think that you can, or that you can't, you are usually right "
.. Henry Ford

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources