Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA to return how many Excel instances are open
Could someone help me with code that will tell me how many instances of
Excel are currently open? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA to return how many Excel instances are open
Hi Tod,
Could someone help me with code that will tell me how many instances of Excel are currently open? Sure (careful with the word-wrap): Public Declare Function GetDesktopWindow Lib "user32" () As Long Public 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 ExcelInstances() As Long Dim hWndDesk As Long Dim hWndXL As Long 'Get a handle to the desktop hWndDesk = GetDesktopWindow Do 'Get the next Excel window hWndXL = FindWindowEx(GetDesktopWindow, hWndXL, "XLMAIN", vbNullString) 'If we got one, increment the count If hWndXL 0 Then ExcelInstances = ExcelInstances + 1 End If 'Loop until we've found them all Loop Until hWndXL = 0 End Function Regards Stephen Bullen Microsoft MVP - Excel Professional Excel Development The most advanced Excel VBA book available www.oaltd.co.uk/ProExcelDev |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need to open 2 Instances of Excel 2007 | Setting up and Configuration of Excel | |||
Open Multible Instances of Excel | Excel Discussion (Misc queries) | |||
Open 2 instances of Excel | Excel Discussion (Misc queries) | |||
Open separate instances of excel | Setting up and Configuration of Excel | |||
to open multiple instances of excel | Excel Discussion (Misc queries) |