I have a VB app that looks at autocad to determine if a dwg file is open. I have run into a problem if the user has more than one instance of Autocad running or if the dwg file that is open still has an active command running such as Pan or Zoom. This throws up a message(Abort, Retry, Ignore) and has an adverse affect on my app. With all that my question would be how do I loop through all the instances of Autocad? I posted my code below to loop through the dwg files to determine if it is open, if it is a message will inform them to save and close the file before my app can "Check the file in" or back to the server. As for the active command I need to pass the instance a Ctrl+C or an Escape character to each file to terminate any active commands.
Public Function AcadLink() As Boolean
Dim h, i As Integer
Dim DwgName As String
AcadLink = False
On Error GoTo nocad
Set AcadApp = GetObject(, "AutoCAD.Application")
For i = 0 To AcadApp.Documents.Count - 1
DwgName = Left(Right(AcadApp.Documents(i).Name, Len(lstCitem) + 4), Len(lstCitem))
If lstCitem = DwgName Then
AcadLink = True
Exit For
End If
Next i
nocad:
End Function
All suggestions, and comments are appreciated, Thanks
Public Function AcadLink() As Boolean
Dim h, i As Integer
Dim DwgName As String
AcadLink = False
On Error GoTo nocad
Set AcadApp = GetObject(, "AutoCAD.Application")
For i = 0 To AcadApp.Documents.Count - 1
DwgName = Left(Right(AcadApp.Documents(i).Name, Len(lstCitem) + 4), Len(lstCitem))
If lstCitem = DwgName Then
AcadLink = True
Exit For
End If
Next i
nocad:
End Function
All suggestions, and comments are appreciated, Thanks