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?
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
CODE
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
RE: Open a new drawing from within Autocad