Form Design

RhinoNeil

Board Regular
Joined
Dec 16, 2010
Messages
54
I have created a form to enter data into my Excel 2003 worksheet, no problem.

But the caption header is showing as a default blue at the moment and I want to change it to my Company's colour scheme (i.e. yellow). Changing "bordercolor" does not change it.

I cannot find anyway of changing the colour of the Cpation header, except by changing the Windows Themes.

Can anybody tell me either how change the colour or remveo it entirely from my form?

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
To remove it:
Code:
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)
Private Const WS_CAPTION As Long = &HC00000

Public Sub RemoveWindowFrame(TargetForm As Object)

' Remove the form's title bar
   Dim hwnd As Long
   'Dim Style As Long
  If Val(Application.Version) < 9 Then
     ' Excel 97 or earlier
     hwnd = FindWindow("ThunderXFrame", TargetForm.Caption)
  Else
     ' Excel 2000 or later
     hwnd = FindWindow("ThunderDFrame", TargetForm.Caption)
  End If
  
  SetWindowLong hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) And Not WS_CAPTION
  
End Sub

Private Sub UserForm_Activate()
   RemoveWindowFrame Me
End Sub

just make sure you have a button to close the form. ;)
 
Upvote 0
I have "copy and pasted" the code into a module in my workbook. Then I added a show command to the subroutine "Private Sub UserForm_Activate()" in front of the line "RemoveWindowFrame Me".

When I run the subroutine, the form appears but still has the border.

What am I doing wrong?
 
Upvote 0
That code needs to be in the userform's code module. Then all you do is show it.
 
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,343
Members
449,219
Latest member
Smiqer

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