ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to make Excel the Top-Most application programmatically? (https://www.excelbanter.com/excel-programming/305744-how-make-excel-top-most-application-programmatically.html)

R Avery

How to make Excel the Top-Most application programmatically?
 
I have Excel checking a file every so often for a particular command,
and whenever it finds a certain command, I want it to bring Excel to the
front and prompt the user.

Similarly, I would like to be able to send Excel to the back whenever
some other command was inside a file.

How could I achieve this? Any help would be appreciated.

Chip Pearson

How to make Excel the Top-Most application programmatically?
 
I don't think you can do this. The closest you can come is to use

AppActivate Application.Caption

This will cause the Excel icon in the Taskbar to blink, but won't
actually make the application active.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"R Avery" wrote in message
...
I have Excel checking a file every so often for a particular

command,
and whenever it finds a certain command, I want it to bring

Excel to the
front and prompt the user.

Similarly, I would like to be able to send Excel to the back

whenever
some other command was inside a file.

How could I achieve this? Any help would be appreciated.




Keith Willshaw[_2_]

How to make Excel the Top-Most application programmatically?
 

"R Avery" wrote in message
...
I have Excel checking a file every so often for a particular command,
and whenever it finds a certain command, I want it to bring Excel to the
front and prompt the user.

Similarly, I would like to be able to send Excel to the back whenever
some other command was inside a file.

How could I achieve this? Any help would be appreciated.


It can be done using the win32 API

In a code module declare the function

Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal
hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long,
ByVal cy As Long, ByVal Wflags As Long) As Long

then get the Excel Windows handle

Dim Winhandle as Long
Winhandle=Application.Hwnd

Then call the following sub

FloatWindow(Winhandle)


Public Sub Floatwindow(Winhandle As Long)
' -------------------------------------
' This routine makes the window who's
' handle is passed always on top
' -------------------------------------

Dim Wflags As Integer
Wflags = 2 Or 1
Call SetWindowPos(Winhandle, -1, 0, 0, 0, 0, Wflags)

End Sub

Keith




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com