I am using 2 excel workbooks arranged horizontally to view a lot of data on a single screen and have a requirement to use as much space as possible.
In case a single excel workbook is open, the name of the program viz. Excel and the Workbook name are displayed in a single title bar. Using the code below, I have been able to remove this single Excel Title bar.
However, in case 2 workbooks are open (and arranged horizontally) in the same instance of Excel, there is an overall Excel window with a title bar (which my code has been able to remove), and then each workbook opens in a window of its own and each workbook has a title bar.
I need help in removing these 2 Workbook title bars. Am posting the code in the hope that it would give some idea to remove the excel workbook title bars as well.
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_Show() ShowTitleBar True End Sub Sub Title_Hide() ShowTitleBar False End Sub Sub ShowTitleBar(bShow As Boolean) Dim lStyle As Long Dim tRect As RECT Dim xlHnd As Long xlHnd = Application.hwnd '// 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
Sample file having code attached for reference.
Also, it seems Ozgrid does not allow upload of pictures so I am unable to upload screenshot of the Workbook title bars that I want removed, but if you open 2 workbooks, arrange them horizontally (use Alt+W+A+O and Enter) and then run my code, you will know which bars to be removed.
Please note: I am not looking for a simple full screen mode alone, but more than that.