LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Bring my modeless userform to the foreground???

I am currently using a special type of modeless userform that
remains visible even when the Excel application is minimized.
I load the form with a pushbutton that calls "Userform1.Show vbModeless".
Additionally, this userform is defined as follows:
---------------------------------------------------------------------------------
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Const GWL_HWNDPARENT As Long = -8
----------------------------------------------------------------------------------
Private Sub UserForm_Initialize()
hWnd = FindWindow("ThunderDFrame", Me.Caption)
SetWindowLongA hWnd, GWL_HWNDPARENT, 0&
End Sub
----------------------------------------------------------------------------------


Since the above userform can sometimes get hidden underneath Excel in the
background, I wanted to be able to bring the form into the foreground if
my pushbutton is pressed again. I use the following code to (attempt)
to achieve this:

Sub Button1_Click()
UserForm1.Visible = True ' Set visible as True will bring to
foreground???
End Sub


The problem is, if I attempt to run the above code in "Button1_Click()", I
get
the following compile error:

"Function or interface marked as restricted, or the function uses an
Automation
type not supported in Visual Basic"

Does anybody know why this error occurred??? What does it mean?? And
what is the best way to bring my userform to the foreground?


 
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
Modeless Userform Roger Excel Programming 2 March 10th 08 08:01 PM
Clicking on chart does not bring to foreground Eric Charts and Charting in Excel 1 August 9th 07 10:12 PM
Modeless userform hngo New Users to Excel 2 July 13th 05 09:23 AM
How do I Bring a window to the foreground? *outlook warning [email protected] Excel Programming 2 December 22nd 04 01:01 AM
modeless userform jacob Excel Programming 1 May 4th 04 02:53 PM


All times are GMT +1. The time now is 08:31 PM.

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"