Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 257
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open Excel in different windows AND open from Outlook? KimD Setting up and Configuration of Excel 0 January 25th 10 07:47 PM
cannot open exel from windows xp in windows vista and visa versa lildiana New Users to Excel 4 February 25th 09 07:26 PM
Excel/Windows cannot find the file I clicked on to open it Red Kite Excel Discussion (Misc queries) 6 March 29th 07 01:42 PM
Open email windows can't open, excel shreadsheet file .xls ? skiz Excel Discussion (Misc queries) 0 October 2nd 05 07:03 PM
Which windows are open? nath Excel Programming 2 August 5th 04 01:51 PM


All times are GMT +1. The time now is 05:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"