- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi to everybody,
I have to modify a small part of each dwg inside a set of 200 DWG, see example "Sheet 100/XX" with "Sheet 100/200". Dwg have been imported from DGN so are not pure autocad and of course a question confirmation of opening will be required before opening. Here the first question: how to trap the confirmation open request dialog box by VBA ? short way could be sendkeys function simulating "enter" as confirmation, but if there will be a better way by VBA could be useful.
The second question is how to modify dwg without open it for editing ? I know that there is a way to have objects inside having access to drawing database and not directly to entity modification, but I'm not so expert with VBA.
Just for start I created a code, of course it's working but require a lot of time into operations... open ->confirmation -> search object and modify it ->save and close, repeat the same operation of 200 files...
Somebody could help me to find a short way ?
Sub MyMacro()
Dim NameOfFile As String
Dim MyPath As String
MyPath = "C:\Users\Utente\Downloads\DWG"
Open MyPath & "\" & "ListDwg.txt" For Input As 1
Do While Not EOF(1)
Input #1, NameOfFile
ThisDrawing.Application.Documents.Open MyPath & "\" & NameOfFile
For Each Object In ThisDrawing.ModelSpace
If TypeOf Object Is AcadText Or AcadMText Then
If Right(Object.TextString, 3) = "/XX" Then
MyString = "/200"
MyString1 = Left(Object.TextString, Len(Object.TextString) - 3)
Object.TextString = MyString1 & MyString
End If
End If
Next
ThisDrawing.Application.ZoomExtents
ThisDrawing.Save
ThisDrawing.Close
Loop
Close #1
End Sub
Solved! Go to Solution.