INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Promoting, selling, recruiting, coursework and thesis posting is forbidden.
VBA How To
Remove the title bar from a userform
Posted: 10 Jun 04
To remove the title bar from a vba userform we need to use the win API so please make sure you're comfortable with this before continuing.
First create a new form, userform2 say, and put the following in the general declaration section:
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 Const GWL_STYLE As Long = (-16) 'The offset of a window's style
Private Const WS_CAPTION As Long = &HC00000 'Style to add a titlebar
Next in the initialize section all you need is the following code:
hwndform = FindWindow("ThunderXframe", UserForm2.Caption)
istyle = GetWindowLong(hwndform, GWL_STYLE)
istyle = istyle And Not WS_CAPTION
X = SetWindowLong(hwndform, GWL_STYLE, istyle)
'ThunderXframe' in the FindWindow call above refers to the userforms class code name that microsoft developers had for EXCEL 97. For EXCEL 2000 applications and up you should use 'ThunderDframe'. No doubt future versions of EXCEL will have their own codes too, look 'em up on google if you need them.
Back to VBA Visual Basic for Applications (Microsoft) FAQ Index
Back to VBA Visual Basic for Applications (Microsoft) Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close