Thread: Form question
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_782_] Leith Ross[_782_] is offline
external usenet poster
 
Posts: 1
Default Form question


Leon;407572 Wrote:
Hi Folks

I have an application wich using an ontime procedure to schedule a
refresh task - updating cells with external data.
That takes a 30 seconds and a userform with a progressbar is shown
while updating.
That works fine if only Excel application have focus.

My problem is that I want Excel to updata even if I have an other
application open and that other application is active. Say Word.

If I have overlapping windows .. Excel in background and word on top
-
I want the progressbar to show up in front of Excel but behind Word..
The progressbar schould be updated while refreshing data to the sheet.
The form schould then be closed in the end,
now tha data is refreshed properly.
Is that to be done?

Cheers


Hello Leon,

Copy this code into a standard VBA module in your project. Place a call
to the macro in the UserForm_Activate event code module.

'================================================= ========
'Returns the Window Handle of the Window
'that is accepting User input.
Public Declare Function GetForegroundWindow Lib "user32.dll" () As
Long

Sub KeepFormOnTop()

Const HWND_TOPMOST As Long = -1
Const SWP_NOMOVE As Long = &H2
Const SWP_NOSIZE As Long = &H1

SetWindowPos GetActiveWindow(), HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE + SWP_NOSIZE

End Sub
'================================================= ========
'
'UserForm Code
Private Sub UserForm_Activate()
KeepFormOnTop
End Sub
'================================================= ========


--
Leith Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=113600