+ Reply to Thread
Results 1 to 2 of 2

List & Open active Windows applications on screen by selecting it in excel cells

Hybrid View

  1. #1
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    List & Open active Windows applications on screen by selecting it in excel cells

    Hello Experts, need your assistance in competing the task..
    Below code gives list of active windows applications on screen.

    however it only provides list.

    Assistance - how do we add code which will help us activate the windows application to foreground on double click

    Example - I have Word, outlook & notepad open on screen, so once i open macro & run the code it will give me list of the applications & all other applications will be in background..

    Notepad
    Outlook
    Word

    Now on double click on Notepad in excel list user should see the Notepad on foreground, it should be activated, maximized & seen on screen.

    Private Declare PtrSafe Function apiGetClassName Lib "user32" Alias _
                    "GetClassNameA" (ByVal hwnd As Long, _
                    ByVal lpClassname As String, _
                    ByVal nMaxCount As Long) As Long
    Private Declare PtrSafe Function apiGetDesktopWindow Lib "user32" Alias _
                    "GetDesktopWindow" () As Long
    Private Declare PtrSafe Function apiGetWindow Lib "user32" Alias _
                    "GetWindow" (ByVal hwnd As Long, _
                    ByVal wCmd As Long) As Long
    Private Declare PtrSafe Function apiGetWindowLong Lib "user32" Alias _
                    "GetWindowLongA" (ByVal hwnd As Long, ByVal _
                   nIndex As Long) As Long
    Private Declare PtrSafe Function apiGetWindowText Lib "user32" Alias _
                    "GetWindowTextA" (ByVal hwnd As Long, ByVal _
                    lpString As String, ByVal aint As Long) As Long
    Private Const mcGWCHILD = 5
    Private Const mcGWHWNDNEXT = 2
    Private Const mcGWLSTYLE = (-16)
    Private Const mcWSVISIBLE = &H10000000
    Private Const mconMAXLEN = 255
    
    Sub ListName()
        Dim xRg As Range
        Dim xStr As String
        Dim xStrLen As Long
        Dim xHandle As Long
        Dim xHandleStr As String
        Dim xHandleLen As Long, xHandleStyle As Long
        On Error Resume Next
        Set xRg = Application.InputBox("Please select a range(single cell):", "!", ActiveWindow.RangeSelection.Address, , , , , 8)
        If xRg Is Nothing Then Exit Sub
        xRg(1).Activate
        xHandle = apiGetWindow(apiGetDesktopWindow(), mcGWCHILD)
        
        Do While xHandle <> 0
            xStr = String$(mconMAXLEN - 1, 0)
            xStrLen = apiGetWindowText(xHandle, xStr, mconMAXLEN)
            If xStrLen > 0 Then
                xStr = Left$(xStr, xStrLen)
                xHandleStyle = apiGetWindowLong(xHandle, mcGWLSTYLE)
                If xHandleStyle And mcWSVISIBLE Then
                    ActiveCell.Value = xStr
                    ActiveCell.Offset(1, 0).Activate
                End If
            End If
            xHandle = apiGetWindow(xHandle, mcGWHWNDNEXT)
            AppActivate (xHandle)
        Loop
       
    End Sub
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  2. #2
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: List & Open active Windows applications on screen by selecting it in excel cells

    Hello Experts, any assistance

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to grab all open windows screen and insert one in each excel sheet
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2017, 02:38 AM
  2. Replies: 1
    Last Post: 05-24-2013, 01:35 PM
  3. Restrict windows switching to other applications, through Excel VBA
    By haripopuri in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 03:44 AM
  4. open Excel with Macros active from windows schedule
    By bagullo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2011, 03:44 AM
  5. Controlling other windows applications
    By PilotC in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-08-2007, 06:38 PM
  6. check Open Excel applications
    By Zurn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2006, 02:29 AM
  7. Replies: 0
    Last Post: 02-28-2006, 06:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1