Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find out what windows are open
Hello everyone.
I remember coming across some type of tutorial/code example that would run in Excel (VBA) and show you all the active window process names or something similar to use in WinAPI calls (for the window handler). I'm just wondering if anyone knows of this, and can point me in the correct direction as I'm having no luck in finding it now. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find out what windows are open
Boy, if someone answers this, NateBuckley, I'd like to know too.
--- "NateBuckley" wrote: I remember coming across some type of tutorial/code example that would run in Excel (VBA) and show you all the active window process names or something similar to use in WinAPI calls (for the window handler). I'm just wondering if anyone knows of this, and can point me in the correct direction as I'm having no luck in finding it now. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find out what windows are open
I think this is it. It came from a previous post but I cant remember when.
This Workbook: Option Explicit Dim cControl As CommandBarButton Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Sheets("Sheet1").Select End Sub Private Sub Workbook_Open() 'Take away the Menu item for now 'Workbook_AddinInstall End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Workbook_AddinUninstall End Sub Private Sub Workbook_AddinInstall() On Error Resume Next Application.CommandBars("Worksheet Menu Bar").Controls("WB Navigator ..qx").Delete Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add With cControl ..Caption = "WB Navigator &q" ..Style = msoButtonCaption ..OnAction = "ShowWorkbooks" End With On Error GoTo 0 End Sub Private Sub Workbook_AddinUninstall() On Error Resume Next Application.CommandBars("Worksheet Menu Bar").Controls("WB Navigator q").Delete On Error GoTo 0 End Sub ------------------------------------------------------------ Module: Sub ShowWorkbooks() Application.ScreenUpdating = False Dim wb As Workbook With UserForm1 ..ListBox1.Clear ..ListBox2.Clear For Each wb In Workbooks .ListBox1.AddItem wb.Name Next Call SortListBox(.ListBox1) .ListBox1.ListIndex = 0 .ListBox1.SetFocus 'MsgBox .ListBox1.Value vListPosition = 0 Do Until .ListBox1.Value = ActiveWorkbook.Name vListPosition = vListPosition + 1 .ListBox1.ListIndex = vListPosition Loop End With UserForm1.Show False End Sub Sub SortListBox1(oLb As MSForms.ListBox) Dim vaItems As Variant Dim i As Long, j As Long Dim vTemp As Variant 'Put the items in a variant array vaItems = oLb.List 'Steal code from John Walkenbachs Excel Power Programming 'with VBA to sort the array For i = LBound(vaItems, 1) To UBound(vaItems, 1) - 1 For j = i + 1 To UBound(vaItems, 1) If vaItems(i, 0) vaItems(j, 0) Then vTemp = vaItems(i, 0) vaItems(i, 0) = vaItems(j, 0) vaItems(j, 0) = vTemp End If Next j Next i 'Clear the listbox oLb.Clear 'Add the sorted array back to the listbox 'For i = LBound(vaItems, 1) To UBound(vaItems, 1) ' oLb.AddItem vaItems(i, 0) 'Next i 'This next code replace the above code by a Microsoft Group comment 04/18/08 oLb.List = vaItems End Sub Sub SortListBox(oLb As MSForms.ListBox) Dim i As Long, j As Long Dim vTemp As Variant 'with VBA to sort the array For i = 0 To oLb.ListCount - 2 For j = i + 1 To oLb.ListCount - 1 If CStr(oLb.List(i, 0)) CStr(oLb.List(j, 0)) Then vTemp = CStr(oLb.List(i, 0)) oLb.List(i, 0) = CStr(oLb.List(j, 0)) oLb.List(j, 0) = vTemp End If Next j Next i End Sub "NateBuckley" wrote: Hello everyone. I remember coming across some type of tutorial/code example that would run in Excel (VBA) and show you all the active window process names or something similar to use in WinAPI calls (for the window handler). I'm just wondering if anyone knows of this, and can point me in the correct direction as I'm having no luck in finding it now. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find out what windows are open
I think this code answers a question you asked in a different thread, Steven.
By the way, I thought last night I had found what Nathan asked for, but it turned out to be a list not of running apps but of objects registered on a PC - the character strings that can be used in a CreateObject call. There were thousands of them, but an extract looks like this: .. .. .. Vsn-Ind: Excel.Chart[.8] Descrip: Microsoft Office Excel Chart Vsn-Ind: [Excel.Sheet.12] Descrip: Microsoft Office Excel 2007 Workbook Vsn-Ind: [Excel.SheetMacroEnabled.12] Descrip: Microsoft Office Excel 2007 Workbook Vsn-Ind: [Excel.SheetBinaryMacroEnabled.12] Descrip: Microsoft Office Excel 2007 Binary Workbook Vsn-Ind: [Word.Document.6] Descrip: Microsoft Word 6.0 - 7.0 Document Vsn-Ind: [Word.Picture.6] Descrip: Microsoft Word 6.0 - 7.0 Picture Vsn-Ind: Word.Document[.8] Descrip: Microsoft Word Document Vsn-Ind: Word.Picture[.8] Descrip: Microsoft Word Picture Vsn-Ind: Word.Basic[.9] Descrip: Microsoft Word Basic Vsn-Ind: Word.Application[.11] Descrip: Microsoft Word Application Vsn-Ind: MSProject.Docfile.4[] Descrip: Microsoft Project Proj95 Serializer Vsn-Ind: Publisher.Application[.11] Descrip: Microsoft Publisher Application .. .. .. --- "Steven" wrote: I think this is it. It came from a previous post but I cant remember when. Private Sub Workbook_AddinInstall() On Error Resume Next Application.CommandBars("Worksheet Menu Bar").Controls("WB Navigator .qx").Delete Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add With cControl .Caption = "WB Navigator &q" .Style = msoButtonCaption .OnAction = "ShowWorkbooks" End With On Error GoTo 0 End Sub Private Sub Workbook_AddinUninstall() On Error Resume Next Application.CommandBars("Worksheet Menu Bar").Controls("WB Navigator q").Delete On Error GoTo 0 End Sub --- "NateBuckley" wrote: I remember coming across some type of tutorial/code example that would run in Excel (VBA) and show you all the active window process names or something similar to use in WinAPI calls (for the window handler). I'm just wondering if anyone knows of this, and can point me in the correct direction as I'm having no luck in finding it now. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to open Excel in different windows AND open from Outlook? | Setting up and Configuration of Excel | |||
cannot open exel from windows xp in windows vista and visa versa | New Users to Excel | |||
Excel/Windows cannot find the file I clicked on to open it | Excel Discussion (Misc queries) | |||
Open email windows can't open, excel shreadsheet file .xls ? | Excel Discussion (Misc queries) | |||
Which windows are open? | Excel Programming |