Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello ,
If anyone knows how to get count of all the instances of excel that are open at a time on the machine? using getobject will reference to the instance of the excel application that was opened first but it will not say how many instances are already open at that point of time. I need this value in a start up of an xla file which runs on loading of excel (2003) If more then one instance are open then I want to exit from furthur loading of xla . Thanks, Nayan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 11, 1:04 pm, Nayan wrote:
Hello , If anyone knows how to get count of all the instances of excel that are open at a time on the machine? using getobject will reference to the instance of the excel application that was opened first but it will not say how many instances are already open at that point of time. I need this value in a start up of an xla file which runs on loading of excel (2003) If more then one instance are open then I want to exit from furthur loading of xla . Thanks, Nayan Here's a VB Script you can use: Dim XLCount Dim oWMI Set oWMI = GetObject("winmgmts:") XLCount = 0 For Each Process in oWMI.InstancesOf("Win32_Process") IF UCASE(Process.Name) = "EXCEL.EXE" THEN XLCount = XLCount + 1 End If Next MSGBOX "EXCEL INSTANCES OPEN: " & XLCount Set oWMI = nothing |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another way -
Private Declare Function FindWindowEx Lib "user32" _ Alias "FindWindowExA" _ (ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String) As Long Function XLcount() As Long Dim hwnd As Long, n As Long Do hwnd = FindWindowEx(0&, hwnd, "XLMAIN", vbNullString) n = n + 1 Loop Until hwnd = 0 XLcount = n - 1 End Function Sub test() MsgBox XLcount End Sub Regards, Peter T "Nayan" wrote in message ... Hello , If anyone knows how to get count of all the instances of excel that are open at a time on the machine? using getobject will reference to the instance of the excel application that was opened first but it will not say how many instances are already open at that point of time. I need this value in a start up of an xla file which runs on loading of excel (2003) If more then one instance are open then I want to exit from furthur loading of xla . Thanks, Nayan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jennifer,
This is working great. Thanks a lot, Nayan "Jennifer" wrote: On Jun 11, 1:04 pm, Nayan wrote: Hello , If anyone knows how to get count of all the instances of excel that are open at a time on the machine? using getobject will reference to the instance of the excel application that was opened first but it will not say how many instances are already open at that point of time. I need this value in a start up of an xla file which runs on loading of excel (2003) If more then one instance are open then I want to exit from furthur loading of xla . Thanks, Nayan Here's a VB Script you can use: Dim XLCount Dim oWMI Set oWMI = GetObject("winmgmts:") XLCount = 0 For Each Process in oWMI.InstancesOf("Win32_Process") IF UCASE(Process.Name) = "EXCEL.EXE" THEN XLCount = XLCount + 1 End If Next MSGBOX "EXCEL INSTANCES OPEN: " & XLCount Set oWMI = nothing |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter,
Its working perfect. Its always good to know more then one method. Thanks , Nayan "Peter T" wrote: Another way - Private Declare Function FindWindowEx Lib "user32" _ Alias "FindWindowExA" _ (ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String) As Long Function XLcount() As Long Dim hwnd As Long, n As Long Do hwnd = FindWindowEx(0&, hwnd, "XLMAIN", vbNullString) n = n + 1 Loop Until hwnd = 0 XLcount = n - 1 End Function Sub test() MsgBox XLcount End Sub Regards, Peter T "Nayan" wrote in message ... Hello , If anyone knows how to get count of all the instances of excel that are open at a time on the machine? using getobject will reference to the instance of the excel application that was opened first but it will not say how many instances are already open at that point of time. I need this value in a start up of an xla file which runs on loading of excel (2003) If more then one instance are open then I want to exit from furthur loading of xla . Thanks, Nayan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Count Multiple Instances of Text in a Cell | Excel Discussion (Misc queries) | |||
Count Multiple Instances of Text in a Cell | Excel Discussion (Misc queries) | |||
Count Multiple Instances of Text in a Cell | Excel Discussion (Misc queries) | |||
Count Multiple Instances of Text in a Cell | Excel Discussion (Misc queries) | |||
A counting formula that won't count multiple instances of same val | Excel Worksheet Functions |