Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture multiple instances of application GetObject()

Status
Not open for further replies.

lrfcbabe

Programmer
Jul 19, 2001
108
0
0
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top