在你的提示下,已经完成了代码编写,谢谢了!
IsOpen = False
For Each acaddoc In acadapp.Documents
If StrComp(acaddoc.Name, MyFileName, vbTextCompare) = 0 Then
IsOpen = True
acaddoc.Activate
Exit For
End If
Next
If IsOpen = False Then acadapp.Documents.Open MyPath & MyFileName
一点建议
IsOpen = False
For Each acaddoc In acadapp.Documents
If StrComp(acaddoc.Name, MyFileName, vbTextCompare) = 0 Then
IsOpen = True
set mydoc=acaddoc
Exit For
End If
Next
If IsOpen = False Then set mydoc=acadapp.Documents.Open MyPath & MyFileName
mydoc.activate