Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Count & Select Window

VBA rookie here.

Is it possible to get VBA to count the number of active applications in
Windows? I dont mean counting the number of Excel workbooks opened within
the Excel application but the number of applications that are active within
Windows itself. Say if I have launched Word, Notepad, Powerpoint, Excel and
SAP application, the count should return 5.

If this is possible, then how can I also get it to Debug.Print each
applications name?

Currentlly, Im using sendkeys "%{TAB}" to tab to-and-fro the next
application. This is very dangerous. With your answer, I hope to get VBA to
activate the intended application rather than using ALT+TAB.

Thanks in advance
--
Edmund
(Using Excel XP)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Count & Select Window

Edmund,

Here's the MS version:
http://support.microsoft.com/kb/175030

And similar in VB
http://vbnet.mvps.org/index.html?cod...entprocess.htm

And using WMI
http://codecomments.com/Visual_Basic/message738136.html

NickHK

"Edmund" wrote in message
...
VBA rookie here.

Is it possible to get VBA to count the number of active applications in
Windows? I don't mean counting the number of Excel workbooks opened within
the Excel application but the number of applications that are active

within
Windows itself. Say if I have launched Word, Notepad, Powerpoint, Excel

and
SAP application, the count should return 5.

If this is possible, then how can I also get it to Debug.Print each
applications' name?

Currentlly, I'm using sendkeys "%{TAB}" to tab to-and-fro the next
application. This is very dangerous. With your answer, I hope to get VBA

to
activate the intended application rather than using ALT+TAB.

Thanks in advance
--
Edmund
(Using Excel XP)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Count & Select Window

Probably mean

http://vbnet.mvps.org/index.html?cod...pprocesses.htm

for the VB way.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"NickHK" wrote in message
...
Edmund,

Here's the MS version:
http://support.microsoft.com/kb/175030

And similar in VB
http://vbnet.mvps.org/index.html?cod...entprocess.htm

And using WMI
http://codecomments.com/Visual_Basic/message738136.html

NickHK

"Edmund" wrote in message
...
VBA rookie here.

Is it possible to get VBA to count the number of active applications in
Windows? I don't mean counting the number of Excel workbooks opened

within
the Excel application but the number of applications that are active

within
Windows itself. Say if I have launched Word, Notepad, Powerpoint, Excel

and
SAP application, the count should return 5.

If this is possible, then how can I also get it to Debug.Print each
applications' name?

Currentlly, I'm using sendkeys "%{TAB}" to tab to-and-fro the next
application. This is very dangerous. With your answer, I hope to get VBA

to
activate the intended application rather than using ALT+TAB.

Thanks in advance
--
Edmund
(Using Excel XP)





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Count & Select Window

Yeah, that's a bit more relevant.

NickHK

"Bob Phillips" wrote in message
...
Probably mean

http://vbnet.mvps.org/index.html?cod...pprocesses.htm

for the VB way.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"NickHK" wrote in message
...
Edmund,

Here's the MS version:
http://support.microsoft.com/kb/175030

And similar in VB
http://vbnet.mvps.org/index.html?cod...entprocess.htm

And using WMI
http://codecomments.com/Visual_Basic/message738136.html

NickHK

"Edmund" wrote in message
...
VBA rookie here.

Is it possible to get VBA to count the number of active applications

in
Windows? I don't mean counting the number of Excel workbooks opened

within
the Excel application but the number of applications that are active

within
Windows itself. Say if I have launched Word, Notepad, Powerpoint,

Excel
and
SAP application, the count should return 5.

If this is possible, then how can I also get it to Debug.Print each
applications' name?

Currentlly, I'm using sendkeys "%{TAB}" to tab to-and-fro the next
application. This is very dangerous. With your answer, I hope to get

VBA
to
activate the intended application rather than using ALT+TAB.

Thanks in advance
--
Edmund
(Using Excel XP)







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Count & Select Window

Im really a rookie with VBA & almost no knowledge of VB.

Ive followed
http://vbnet.mvps.org/index.htmlcode...pprocesses.htm , copied
its codes into VBA & successfully run tested it where it return results on
the €śprocesses€ť that are active in Windows. The results are exactly like what
I get to see in Task Managers Tab #2. But this is not exactly what I needed.

What I actually need is contained within Tab # 1 (tab named: Applications)
in Task Manager. For example, say if there are 10 tasks listed in tab #1 of
Task Manager, how can I get VBA to €śSwitch To€ť the task that I needed?

(a) How can I get VBA to list down each tasks in a spreadsheet or by
Debug.Print (the list of tasks in Task Manger Tab #1).
(b) After achieving the above, how can I get VBA to €śSwitch To€ť the task of
my choice? I need the above steps for assurance because my procedure will
later be using SendKeys to perform data entry on a NON-MS Office based
application.

Im aware that [Application.SendKeys "%{TAB <repeatition #}", True] can
help do the switching but its simply too dangerous because it does not
verify if it has activated the intended screen. It will be a disaster if my
data entry (via SendKeys) is consequently executed on the wrong screen.

Thanking you in advance for the big favor.

--
Edmund
(Using Excel XP)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Count & Select Window

Edmund,
If you know which the class name of the app and/or it's title you are trying
to "connect" to, then FindWindow API would be easier.
I assume all the running processes are of no concern to you.

<From 'KPD-Team 1998: URL: http://www.allapi.net/ :E-Mail:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA"
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)
As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal
nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form_Load()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) +
"Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
</From 'KPD-Team 1998: URL:
http://www.allapi.net/ :E-Mail:


NickHK

"Edmund" wrote in message
...
I'm really a rookie with VBA & almost no knowledge of VB.

I've followed
http://vbnet.mvps.org/index.htmlcode...pprocesses.htm , copied
its codes into VBA & successfully run tested it where it return results on
the "processes" that are active in Windows. The results are exactly like

what
I get to see in Task Manager's Tab #2. But this is not exactly what I

needed.

What I actually need is contained within Tab # 1 (tab named: Applications)
in Task Manager. For example, say if there are 10 tasks listed in tab #1

of
Task Manager, how can I get VBA to "Switch To" the task that I needed?

(a) How can I get VBA to list down each tasks in a spreadsheet or by
Debug.Print (the list of tasks' in Task Manger Tab #1).
(b) After achieving the above, how can I get VBA to "Switch To" the task

of
my choice? I need the above steps for assurance because my procedure will
later be using SendKeys to perform data entry on a NON-MS Office based
application.

I'm aware that [Application.SendKeys "%{TAB <repeatition #}", True] can
help do the switching but it's simply too dangerous because it does not
verify if it has activated the intended screen. It will be a disaster if

my
data entry (via SendKeys) is consequently executed on the wrong screen.

Thanking you in advance for the big favor.

--
Edmund
(Using Excel XP)



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
Lost sum,count,averge,etc shortcut window Suzanne Excel Discussion (Misc queries) 2 June 6th 08 04:08 PM
How to pre-select/highlite contents in input window. saziz[_62_] Excel Programming 0 January 18th 06 07:35 PM
How to stop the 'select sheet' window pop up deepakmehta Excel Programming 2 December 18th 05 10:53 PM
Select a sheet and activate a Window Hari Prasadh Excel Programming 6 January 31st 05 10:01 AM


All times are GMT +1. The time now is 06:18 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"