Remove Userform Caption And Make Modeless

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
I got this code from another thread and the code is great EXCEPT, I would like my userform to be modeless.

I changed the script to vbmodeless but the form is still locked in modal mode.

Any help would be appreciated

Code:
*** Place this code In a User Form *** 
 
Option Explicit 
 
Private Sub UserForm_Initialize() 
     
    Call RemoveCaption(Me) 
     
End Sub 
 
*** Place this code In a Module *** 
 
Option Explicit 
 
Private Declare Function FindWindow Lib "User32" _ 
Alias "FindWindowA" ( _ 
ByVal lpClassName As String, _ 
ByVal lpWindowName As String) As Long 
 
Private Declare Function GetWindowLong Lib "User32" _ 
Alias "GetWindowLongA" ( _ 
ByVal hwnd As Long, _ 
ByVal nIndex As Long) As Long 
 
Private Declare Function SetWindowLong Lib "User32" _ 
Alias "SetWindowLongA" (ByVal hwnd As Long, _ 
ByVal nIndex As Long, _ 
ByVal dwNewLong As Long) As Long 
 
Private Declare Function DrawMenuBar Lib "User32" ( _ 
ByVal hwnd As Long) As Long 
 
Sub RemoveCaption(objForm As Object) 
     
    Dim lStyle          As Long 
    Dim hMenu           As Long 
    Dim mhWndForm       As Long 
     
    If Val(Application.Version) < 9 Then 
        mhWndForm = FindWindow("ThunderXFrame", objForm.Caption) 'XL97
    Else 
        mhWndForm = FindWindow("ThunderDFrame", objForm.Caption) 'XL2000+
    End If 
    lStyle = GetWindowLong(mhWndForm, -16) 
    lStyle = lStyle And Not &HC00000 
    SetWindowLong mhWndForm, -16, lStyle 
    DrawMenuBar mhWndForm 
     
End Sub 
 
Sub ShowForm() 
     
    UserForm1.Show False 
     
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
To double check, near the bottom you tried:

<font face=Courier New>UserForm1.Show (vbModeless)</FONT>

other than that I may not be much help.
 
Upvote 0
Thanks repairman, yes I tried it but for some reason within the API script it must lock the form to modal, I guess so that the form is the foremost front window, but not entirely sure.
 
Upvote 0
Well this next bit is totally a guess..

What if you were to place:

<font face=Courier New>Me.Show (vbModeless)</FONT>

after
Call RemoveCaption(Me)

??

Code:
Private Sub UserForm_Initialize() 
     
    Call RemoveCaption(Me) 
    Me.Show (vbModeless)
End Sub
 
Upvote 0
It still remains modal, I'm guessing that a part of the API script locks it and therefore would need to be changed, but I have absolutely no knowledge about API's.
 
Upvote 0
Try putting the
Code:
Sub ShowUserForm()
    UserForm1.Show vbModeless
End Sub
in a standard module or sheet module rather than the UserForm1 module.
 
Upvote 0
Still no joy, If I put the script in it's own module it is now removing the actual excel title bar rather than the userform title bar.
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,003
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top