Workbook Caption/ Title bar

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,066
I use the following script to remove the userform caption, however, sometimes it decides to remove the workbook caption instead, can someone please provide a script that I can use to redraw/ show the workbook caption.

Code:
'Option Private Module
'Returns the Window Handle of the Window
'that is accepting User input.
 Public Declare Function GetForegroundWindow _
   Lib "User32.dll" () As Long

 Private Declare Function GetWindowLong _
  Lib "User32.dll" _
    Alias "GetWindowLongA" _
     (ByVal hwnd As Long, _
      ByVal nIndex As Long) As Long
               
 Private Declare Function SetWindowLong _
  Lib "User32.dll" _
    Alias "SetWindowLongA" _
     (ByVal hwnd As Long, _
      ByVal nIndex As Long, _
      ByVal dwNewLong As Long) As Long

'Redraw the Icons on the Window's Title Bar
 Private Declare Function DrawMenuBar _
   Lib "User32.dll" _
    (ByVal hwnd As Long) As Long

 Private Const GWL_STYLE As Long = (-16)
 Private Const WS_CAPTION = &HC00000

Sub RemoveCaption1()

  Dim BitMask As Long
  Dim hwnd As Long
  Dim WindowStyle As Long
  
    hwnd = GetForegroundWindow
    WindowStyle = GetWindowLong(hwnd, GWL_STYLE)

    BitMask = WindowStyle And (Not WS_CAPTION)

    Call SetWindowLong(hwnd, GWL_STYLE, BitMask)
    Call DrawMenuBar(hwnd)
   
End Sub
I have tried application.caption="" but nothing happens
 
I have tried a wintimer is that the same as an api timer, because the wintimer didn't work, it wouldn't update.

Do you have an example API timer that you could include on the workbook that I sent you so that i.e. textbox1 would have an updating clock, if you can get me started with one that works I could go from there and change it to suite.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Leith,

I have added a workbook on the following link that has 2 examples of my wintimer function.

The 1st one works as it is not pinned to the screen permanently so updates fine.

The 2nd one will not update as it is pinned to the screen.

You will need to copy and paste the link into your browser.

http://jt7.angelfire.com/TESTBOOK.xls
 
Upvote 0
Leith,

I have found an API timer on the internet and have managed to incorporate it into my userform and it is working well.

Thanks for all your time and help.
 
Upvote 0

Forum statistics

Threads
1,223,152
Messages
6,170,389
Members
452,323
Latest member
GoJones

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