LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Userform on top z-order?

Rob,

If you are showing the form modelessly (e.g, UserForm1.Show vbModeless), you
can use code in the form's code module like

Private Declare Function SetParent Lib "user32" ( _
ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Declare Function SetForegroundWindow Lib "user32" ( _
ByVal hwnd As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Sub UserForm_Initialize()
Dim XLHWnd As Long
Dim MeHWnd As Long

XLHWnd = Application.hwnd
MeHWnd = FindWindow("ThunderDFrame", Me.Caption)
If (MeHWnd 0) And (XLHWnd 0) Then
SetParent MeHWnd, XLHWnd
SetForegroundWindow (MeHWnd)
End If
End Sub

Note that this should be used ONLY if you are showing the form modelessly.
Do not use it if you are showing the form modally.

See www.cpearson.com/excel/SetParent.aspx for more details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Rob" wrote in message
...
I don't want to override the other program, I just want to bring this
userform to the top. Is there any way to do that?

"JLGWhiz" wrote:

If the L-bar is not produced by Windows software, you might have a
problem
trying to use VBA to override it.

"Rob" wrote:

Hi, I just have a quick question for you experts:

I'm designing an excel sheet for which users would be able to use a
userform
to enter data. Now, having it enter data is easy, but I'm having a
problem
bringing the userform to the top of all other windows.

At my work, we have what's called an "L-bar" around the edge of our
screen,
which stays at the top of all our other windows, and limits the window
space
we can use. I would like the userform to be able to be placed on top of
this
"L-bar", in the top most z-order, so it won't take up any more of the
very
little window space we have already. I tried making the userform
modeless,
but it doesnt really help when excel itself cannot even go on top of
this
"L-bar"!

Is there any way that I could make the userform (or any other data
entry
form) have the highest z-order in the system?


Thank you,

-Robert G.


 
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
Sort order via excel userform combobox [email protected] Excel Programming 3 July 17th 07 03:29 PM
Tab Order skips over two fields in UserForm DRK Excel Programming 0 June 21st 06 08:02 PM
UserForm Tab Order PokerZan Excel Programming 1 July 22nd 05 12:48 AM
Tab Order On A UserForm Minitman[_4_] Excel Programming 1 November 5th 04 11:01 PM
What order does VBA look at userform controls? Brad Patterson Excel Programming 3 July 17th 03 03:46 AM


All times are GMT +1. The time now is 09:17 AM.

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

About Us

"It's about Microsoft Excel"