ThisDrawing.Application.Documents.Open
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi every one,
I have a VBA marco which opens (one by one) all the DWGs in a specific folder and subfolders.
After opening and closing a few files, Autocad needs a least 5 minutes until the file is opened.
Actually I think that at that point the file is already loaded and opened.
Autocad seems to be checking something in background (not part of my macro).
As I have +/-2200 files to open and apply some changes to them with the macro, it would take 2200 files * 5 minutes = 11000 minutes (= 183 hours or 7 days).
The part of the macro which applies the changes to the drawing just last for less than second.
The macro looks like this (reduced for message propose...):
Sub ListSubFolder(subFolders As Scripting.Folders)
Dim fileItem As Scripting.File
Dim subFolder As Scripting.Folder
For Each subFolder In subFolders
If subFolder.subFolders.Count > 0 Then
ListSubFolder subFolder.subFolders
End If
If subFolder.Files.Count > 0 Then
For Each fileItem In subFolder.Files
If fileItem.Type = "AutoCAD Drawing" Then
' this is the line where the waiting takes place...
ThisDrawing.Application.Documents.Open fileItem.Path
' on the COMMANDLINE I see that the file is opened.
' from this point on nothing seems to hapen expept that the CPU usage is at 100%
' and Memory usage at it's maximum.
' the computer gets so slow that all I can do is sit and wait (like Sydney Youngblood...)
currFilename = ThisDrawing.Name ' for later control in macro
' run my macro here, it takes less than a second to step to the next line
ThisDrawing.Save
End If
Next fileItem
End If
Next subFolder
End Sub
So if someone knows why this is like it is until I get retired, I would be very happy and pleased.
Thank you.