×
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

Open a new drawing from within Autocad

Open a new drawing from within Autocad

Open a new drawing from within Autocad

(OP)
I am doing a program that uses VBA to open, Center, Zoom and then time stamp a drawing in AUTOCAD. I can do everything else, but how do I open a different drawing using VBA from within autocad?

Just to clarify, I have 10 drawings in a set on my engineering directory, I want to open each one individually, center the viewport,zoom to extents, and then save and close the drawing. So how do I open the second drawing from VBA?

RE: Open a new drawing from within Autocad

You need to use code like:

CODE

Sub OpenFiles()
    Dim CurrentDwg As AcadDocument
    Dirname = "C:\Documents and Settings\Mala Singh\My Documents\"
    Dim DwgNames(1 To 10)
    DwgNames(1) = "Dwg1"
    DwgNames(2) = "Dwg2"
    DwgNames(3) = "Dwg3"
    DwgNames(4) = "Dwg4"
    DwgNames(5) = "Dwg5"
    DwgNames(6) = "Dwg6"
    DwgNames(7) = "Dwg7"
    DwgNames(8) = "Dwg8"
    DwgNames(9) = "Dwg9"
    DwgNames(10) = "Dwg10"
    For i = 1 To 10
        DwgName = Dirname & DwgNames(i) & ".dwg"
        Set CurrentDwg = Application.Documents.Open(DwgName)
        'Put remaining code here...
    Next i
End Sub

Replace DirName with your actual folder path (remember to end it with a backslash '\').
Replace the drawing names with the actual drawing names (without .dwg extension).

Hope this helps...


Mala Singh
'Dare to Imagine'

RE: Open a new drawing from within Autocad

(OP)
WOW! Thanks Mala. I'll check it out and let you know.

RE: Open a new drawing from within Autocad

(OP)
That works MALA, You rock!

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