Excel VBA Hide ScrollBars
Can anyone explain to me why the following code works sometime and not at other times.
If ActiveWindow.DisplayHorizontalScrollBar = False Then ActiveWindow.DisplayHorizontalScrollBar = True
If ActiveWindow.DisplayVerticalScrollBar = False Then ActiveWindow.DisplayVerticalScrollBar = True
I am trying to have the scroll bars activate when I activate a sheet. I use similar code to deactivate them once I leave the sheet.
I have tried this in both the Sheet.activate module and then in a separate module in a macro that takes me from to the sheet.
It seems that often, the very first time I run it, I get an error message saying I am unable to set the property. ALso happens when I switch from a workbook back to this one, (usually one sheet before this sheet, and then press my command button to take me to the sheet). Funny thing is that if I press the button again, (right after pressing ok to clear the error message), it works.
I can even include an On Error Resume Next statement, and still get my error message.
Any suggestions?
Re: Excel VBA Hide ScrollBars
Quote:
Originally posted by TheFIDDLER
I am trying to have the scroll bars activate when I activate a sheet. I use similar code to deactivate them once I leave the sheet.
Just an observation.. When excel activates and deactivates the scroll bar it does it for the actual workbook, not just that individual worksheet.
You can remove the scrollbars whenever your workbook is loaded and remove them when its exited but not on each sheet within the book..