HIDE TITLE BAR For EXCEL 2007 ???

Nestle

New Member
Joined
Aug 13, 2006
Messages
5
Does any one know how to hide the title bar in VBA code for Excel 2007, the code for 2003 Excel doesn't hide everything in 2007. I just want to see cells on the screen. I can do this in 2003 VBA, but 2007 version is killing me.

Help please,

Nestle
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I don't know the code you are using for xl2003, but fullscreen mode sounds like it might work. (disclaimer: I haven't tried this on xl2007, but I will tomorrow morning)

Code:
Application.DisplayFullScreen = True
 
Upvote 0
Thanks JWiser for replying, but that is the first thing I tried, John Walkenbach wrote me and said it couldn't be done, case closed.
 
Upvote 0
Yes I know I'm responding to an OLD post, but I wanted anyone else looking for this solution to know - this IS doable in Excel 2007. I had to tweak some code I found here to work with Excel '07, but I now have my sheet displaying completely full-screen, with no title bar, row/column headers, nothing but cells. Basically the old code was unable to find the Excel window from which to remove the title bar (FindWindow kept returning 0). That's fixed and it works GREAT.

Try this updated code. Use Title_Toggle to switch between fullscreen mode (with no title bars or other encumberances) and normal mode.


Code:
Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Enum ESetWindowPosStyles
    SWP_SHOWWINDOW = &H40
    SWP_HIDEWINDOW = &H80
    SWP_FRAMECHANGED = &H20
    SWP_NOACTIVATE = &H10
    SWP_NOCOPYBITS = &H100
    SWP_NOMOVE = &H2
    SWP_NOOWNERZORDER = &H200
    SWP_NOREDRAW = &H8
    SWP_NOREPOSITION = SWP_NOOWNERZORDER
    SWP_NOSIZE = &H1
    SWP_NOZORDER = &H4
    SWP_DRAWFRAME = SWP_FRAMECHANGED
    HWND_NOTOPMOST = -2
End Enum
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Sub Title_Toggle()
    ShowTitleBar Application.DisplayFullScreen
End Sub

Sub ShowTitleBar(bShow As Boolean)
Dim lStyle As Long
Dim tRect As RECT
Dim sWndTitle As String
Dim xlhnd

'// Find window handle
sWndTitle = Application.Caption '// Old code used "Microsoft Excel - " & ActiveWindow.Caption 
xlhnd = FindWindow("XLMAIN", sWndTitle) '// Old code did not have class name

'// Get the window's position:
GetWindowRect xlhnd, tRect

'// Show the Title bar ?
If Not bShow Then
    lStyle = GetWindowLong(xlhnd, GWL_STYLE)
    lStyle = lStyle And Not WS_SYSMENU
    lStyle = lStyle And Not WS_MAXIMIZEBOX
    lStyle = lStyle And Not WS_MINIMIZEBOX
    lStyle = lStyle And Not WS_CAPTION
Else
    lStyle = GetWindowLong(xlhnd, GWL_STYLE)
    lStyle = lStyle Or WS_SYSMENU
    lStyle = lStyle Or WS_MAXIMIZEBOX
    lStyle = lStyle Or WS_MINIMIZEBOX
    lStyle = lStyle Or WS_CAPTION
End If

SetWindowLong xlhnd, GWL_STYLE, lStyle
Application.DisplayFullScreen = Not bShow

'// Ensure the style is set and makes the xlwindow the
'// same size, regardless of the title bar.
SetWindowPos xlhnd, 0, tRect.Left, tRect.Top, tRect.Right - tRect.Left, tRect.Bottom - tRect.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED

End Sub
 
Upvote 0
That works amazingly great! However, when the full screen mode is up there is still the ability to move the mouse to the far right and far bottom and right-click. There is a small border that runs on the right side and bottom of the screen. Is there a way to remove those borders so that someone cannont right click on them?

Thank you.
 
Upvote 0
Hi taneralan,

I agree, this is a great routine. Are you running this in XL2003? That's the only time I get any "borders" that you're referring to - XL2007 seems to work fine for me. If so, try adding this to the end of the routine:

Application.WindowState = xlNormal
Application.WindowState = xlMaximized

Hope I understood your question.

regards,

Dave
 
Upvote 0
Hi taneralan,

Just an idea ....

I replied to your question too hastily, I think I may have discovered those "borders" you were referring to, using XL2007.

I clicked the restore button on the Excel window, then resized to fill the screen by dragging the edges. Then running the routine did indeed leave me with the bottom/right borders you mentioned.

However, if I maximized Excel before running the routine, I did not have those borders.

Hope this was helpful.

regards,

Dave
 
Upvote 0
I will check that out. I figured out how to disable that command bar somewhat which solved the problem also. Thanks for your response.
 
Upvote 0
Sorry to resurrect an old thread (again), but I've noticed that the above code (in Excel 2010) gets rid of everything except a thin border to the right. A minor annoyance, to be sure, but an annoyance nonetheless.

I probably wouldn't have even noticed the border, excep that my background was set to black, making the grayish border stand out. Any ideas on how to get rid of it?

Foul
 
Upvote 0

Forum statistics

Threads
1,215,923
Messages
6,127,721
Members
449,399
Latest member
VEVE4014

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