Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Horizontal Scrollbar partially Hidden by Taskbar

When I run the code below, the horizontal scrollbar and status bar are
partially hidden by the taskbar. If I resize the taskbar, the status bar and
scrollbar appear unobstructed above the taskbar, but without resizing the
taskbar they remain partially hidden.

Is there anyway I can make it so that the status bar and horizontal bar are
unobstructed from the outset automatically?

Thanks

Sub Auto_open()

With Application
.DisplayFullScreen = True
.ScreenUpdating = False
.DisplayFormulaBar = False
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = False
'.CommandBars("Formatting").Visible = False
'.CommandBars("Drawing").Visible = False
'.CommandBars("Control Toolbox").Visible = False


End With



Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = False
End With
Next
Worksheets(current_screen).Select
With Application '

End With
Range("A1").Select



End Sub

Sub auto_close()

With Application
.DisplayFullScreen = False
.ScreenUpdating = False
.DisplayFormulaBar = True
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = True
'.CommandBars("Formatting").Visible = True
'.CommandBars("Drawing").Visible = True
'.CommandBars("Control Toolbox").Visible = True
End With
Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With
Next
Worksheets(current_screen).Select
With Application '
End With

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Horizontal Scrollbar partially Hidden by Taskbar

I would guess you have your Taskbar set to AlwaysOnTop. If so, it would seem
that Excel fills the whole Desktop, ignoring the height of the Taskbar when
set to .DisplayFullScreen = True.
I suppose this is the correct behaviour, because Excel IS filling the screen
; it's just that you force your taskbar on top of it. But then it should not
resize to accomodate the taskbar later.

One way would be to make you own FullScreen routine, hiding the required
elements and setting the Application height. A SysInfo control or one of the
API methods below will give you the required height :
With SysInfo1
Debug.Print .WorkAreaHeight, Application.Height * 20
End With
Or use the API.
http://www.vb-helper.com/howto_center_form.html

Otherwise, I was thinking you could change the taskbar size and broadcast
the change.
Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage
As Long, pData As APPBARDATA) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Const ABM_NEW = &H0
Const ABM_REMOVE = &H1
Const ABM_QUERYPOS = &H2
Const ABM_SETPOS = &H3 'Sets the size and screen position
of an appbar
Const ABM_GETSTATE = &H4
Const ABM_GETTASKBARPOS = &H5
Const ABM_ACTIVATE = &H6
Const ABM_GETAUTOHIDEBAR = &H7
Const ABM_SETAUTOHIDEBAR = &H8
Const ABM_WINDOWPOSCHANGED = &H9 'Notifies the system when an appbar'
s position has changed.

Const ABN_STATECHANGE = &H0
Const ABN_POSCHANGED = &H1
Const ABN_FULLSCREENAPP = &H2
Const ABN_WINDOWARRANGE = &H3

Const ABS_AUTOHIDE = &H1
Const ABS_ALWAYSONTOP = &H2

Const ABE_LEFT = 0
Const ABE_TOP = 1
Const ABE_RIGHT = 2
Const ABE_BOTTOM = 3

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long ' message specific
End Type

Private Sub ToggleTaskbar()
'Based on example from :KPD-Team 1999 URL, http://www.allapi.net/
Dim ABD As APPBARDATA, Ret As Long
Dim OldHeight As Long

With ABD
.cbSize = Len(ABD)
.hwnd = FindWindow("Shell_TrayWnd", vbNullString)

'Get the taskbar's position
SHAppBarMessage ABM_GETTASKBARPOS, ABD
'Save the current .Top
OldHeight = .rc.Bottom - .rc.Top
'Decrease the .Top
ABD.rc.Top = ABD.rc.Top - OldHeight
'Set the new .Top
SHAppBarMessage ABM_SETPOS, ABD
'Broadcast the change
SHAppBarMessage ABM_WINDOWPOSCHANGED, ABD
'Set back to the original .Top
.rc.Top = .rc.Bottom - OldHeight
SHAppBarMessage ABM_SETPOS, ABD
'Broadcast the change
SHAppBarMessage ABM_WINDOWPOSCHANGED, ABD
End With
End Sub

But this does NOT change the Windows taskbar, as apparently it does not
respond to the ABM_SETPOS message.
Spy++ can reveals the messages sent to the taskbar, but I'm not sure yet
which one is used when you manually resize the taskbar.
Let you know.

NickHK

"Jon5001" wrote in message
...
When I run the code below, the horizontal scrollbar and status bar are
partially hidden by the taskbar. If I resize the taskbar, the status bar

and
scrollbar appear unobstructed above the taskbar, but without resizing the
taskbar they remain partially hidden.

Is there anyway I can make it so that the status bar and horizontal bar

are
unobstructed from the outset automatically?

Thanks

Sub Auto_open()

With Application
.DisplayFullScreen = True
.ScreenUpdating = False
.DisplayFormulaBar = False
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = False
'.CommandBars("Formatting").Visible = False
'.CommandBars("Drawing").Visible = False
'.CommandBars("Control Toolbox").Visible = False


End With



Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = False
End With
Next
Worksheets(current_screen).Select
With Application '

End With
Range("A1").Select



End Sub

Sub auto_close()

With Application
.DisplayFullScreen = False
.ScreenUpdating = False
.DisplayFormulaBar = True
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = True
'.CommandBars("Formatting").Visible = True
'.CommandBars("Drawing").Visible = True
'.CommandBars("Control Toolbox").Visible = True
End With
Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With
Next
Worksheets(current_screen).Select
With Application '
End With

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Horizontal Scrollbar partially Hidden by Taskbar

Seems that Excel is not sizing itself correctly, as a call to SetWindowPos
with the same dimensions retrived from GetWindowRect jogs it the correct
workarea.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
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

Const SWP_NOACTIVATE = &H10
Const SWP_NOZORDER = &H4

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

Sub Auto_open()
Dim XLhwnd As Long
Dim RetVal As Long
Dim WndRect As RECT

XLhwnd = FindWindow("XLMAIN", Application.Caption)
RetVal = GetWindowRect(XLhwnd, WndRect)

With Application
.DisplayFullScreen = True

RetVal = SetWindowPos(XLhwnd, 0, WndRect.Left, WndRect.Top,
WndRect.Right, WndRect.Bottom, SWP_NOZORDER Or SWP_NOACTIVATE)
...rest of your code

NickHK

"Jon5001" wrote in message
...
When I run the code below, the horizontal scrollbar and status bar are
partially hidden by the taskbar. If I resize the taskbar, the status bar

and
scrollbar appear unobstructed above the taskbar, but without resizing the
taskbar they remain partially hidden.

Is there anyway I can make it so that the status bar and horizontal bar

are
unobstructed from the outset automatically?

Thanks

Sub Auto_open()

With Application
.DisplayFullScreen = True
.ScreenUpdating = False
.DisplayFormulaBar = False
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = False
'.CommandBars("Formatting").Visible = False
'.CommandBars("Drawing").Visible = False
'.CommandBars("Control Toolbox").Visible = False


End With



Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = False
End With
Next
Worksheets(current_screen).Select
With Application '

End With
Range("A1").Select



End Sub

Sub auto_close()

With Application
.DisplayFullScreen = False
.ScreenUpdating = False
.DisplayFormulaBar = True
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = True
'.CommandBars("Formatting").Visible = True
'.CommandBars("Drawing").Visible = True
'.CommandBars("Control Toolbox").Visible = True
End With
Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With
Next
Worksheets(current_screen).Select
With Application '
End With

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Horizontal Scrollbar partially Hidden by Taskbar

Thanks! This solution works like a charm.

"NickHK" wrote:

Seems that Excel is not sizing itself correctly, as a call to SetWindowPos
with the same dimensions retrived from GetWindowRect jogs it the correct
workarea.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
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

Const SWP_NOACTIVATE = &H10
Const SWP_NOZORDER = &H4

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

Sub Auto_open()
Dim XLhwnd As Long
Dim RetVal As Long
Dim WndRect As RECT

XLhwnd = FindWindow("XLMAIN", Application.Caption)
RetVal = GetWindowRect(XLhwnd, WndRect)

With Application
.DisplayFullScreen = True

RetVal = SetWindowPos(XLhwnd, 0, WndRect.Left, WndRect.Top,
WndRect.Right, WndRect.Bottom, SWP_NOZORDER Or SWP_NOACTIVATE)
...rest of your code

NickHK

"Jon5001" wrote in message
...
When I run the code below, the horizontal scrollbar and status bar are
partially hidden by the taskbar. If I resize the taskbar, the status bar

and
scrollbar appear unobstructed above the taskbar, but without resizing the
taskbar they remain partially hidden.

Is there anyway I can make it so that the status bar and horizontal bar

are
unobstructed from the outset automatically?

Thanks

Sub Auto_open()

With Application
.DisplayFullScreen = True
.ScreenUpdating = False
.DisplayFormulaBar = False
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = False
'.CommandBars("Formatting").Visible = False
'.CommandBars("Drawing").Visible = False
'.CommandBars("Control Toolbox").Visible = False


End With



Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = False
End With
Next
Worksheets(current_screen).Select
With Application '

End With
Range("A1").Select



End Sub

Sub auto_close()

With Application
.DisplayFullScreen = False
.ScreenUpdating = False
.DisplayFormulaBar = True
.DisplayScrollBars = True
.DisplayStatusBar = True
'.CommandBars("Standard").Visible = True
'.CommandBars("Formatting").Visible = True
'.CommandBars("Drawing").Visible = True
'.CommandBars("Control Toolbox").Visible = True
End With
Dim current_screen As String
Dim ws
On Error Resume Next
current_screen = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
ws.Select
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With
Next
Worksheets(current_screen).Select
With Application '
End With

End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Troubleshoot horizontal scrollbar LinDee Excel Worksheet Functions 1 September 11th 06 06:27 PM
Horizontal Scrollbar tikchye_oldLearner57 New Users to Excel 2 March 27th 06 06:42 PM
Needless Horizontal scrollbar in Listbox Ken Soenen Excel Programming 2 February 21st 06 04:13 PM
Horizontal Scrollbar For Lisbox Justin Starnes[_2_] Excel Programming 5 October 20th 04 11:26 AM
Horizontal scrollbar in ListBox Anirban Excel Programming 2 October 14th 04 02:05 PM


All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"