Author Topic: set focus  (Read 1865 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
set focus
« on: August 17, 2007, 07:56:21 PM »
Could this be done?

In VBA, you could check for # of instances of Acad, then set focus to second instance, close dwg, and open in first instance. The button would work in either one. Pseudo thinking out loud...


  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: set focus
« Reply #1 on: August 17, 2007, 08:44:44 PM »
You can, but it is not as simple as it sounds. To check for the number of instances of AutoCAD, you would need to use API calls, then you would need to be able to reference the application in order to do what is suggested. It is not impossible, but it is somewhat complex.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on @kblackie


  • Guest
Re: set focus
« Reply #2 on: August 17, 2007, 11:27:16 PM »
Thanks Keith


  • Guest
Re: set focus
« Reply #3 on: August 20, 2007, 01:08:45 PM »
Here's a start.  This will print on the Immediate window the number of instances running.

Code: [Select]
Public Sub HowManyAcads()
    Debug.Print TallyPrograms("acad.exe")
End Sub

Private Function TallyPrograms(ByRef EXEName As String)
    Dim cmd As String
    cmd = "SELECT * FROM Win32_Process WHERE Name='" & EXEName & "'"
    TallyPrograms = GetObject("winmgmts:").ExecQuery(cmd).Count
End Function


  • Water Moccasin
  • Posts: 1882
Re: set focus
« Reply #4 on: August 20, 2007, 08:51:20 PM »
It's a keeper Matt. Cheers.