Hello All.
I'm having an odd problem with SheetActivate which is (sort of) not firing for a specific worksheet, and wondered if anyone could assist.
My code is:
The aim is to go fullscreen and remove scrollbars for one sheet, and revert to normal display for all others.
The first odd thing is that the code does not work when Timesheet is activated. The expression [bold]sh.Name = "Timesheet"[/bold] evaluates correctly to TRUE, and the debug.print line works, but the scrollbars are not removed, and the fullscreen does not activate. Oddly, if I place a breakpoint on any of those four lines, execution does not break.
The second odd thing occurs if I remove the comment marker before the MsgBox line. Selecting any sheet except timesheet, the Msgbox appears *after* the selected sheet has been displayed. Selecting Timesheet, the Msgbox appears *before* the worksheet is displayed.
The Timesheet sheet contains some complex formulae, including some dynamic ranges, charts and linked pictures, and events trapping RightClick, DoubleClick and SelectionChange but I can't see how this would affect sheet activation. None of those events are running on sheet activation. For completeness, there is no other code running in Workbook_SheetDeactivate, or the individual sheets Activate and Deactivate events.
If anyone can cast light on this mysterious oddity, I would be very grateful!
Cheers in advance,
Andy.
-------
The joke cannot be found
[sup]The funny quote you are looking for might have been removed, had its name changed, or is temporarily unavailable.[/sup]
I'm having an odd problem with SheetActivate which is (sort of) not firing for a specific worksheet, and wondered if anyone could assist.
My code is:
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Debug.Print "activating sheet: " & Sh.Name
If Sh.Name = "Timesheet" Then
Debug.Print "turn off scrollbars, enable fullscreen"
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayVerticalScrollBar = False
Application.DisplayFullScreen = True
Else
Debug.Print "turn on scrollbars, disable fullscreen"
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayVerticalScrollBar = True
Application.DisplayFullScreen = False
End If
'MsgBox "Welcome to " & Sh.Name
End Sub
The first odd thing is that the code does not work when Timesheet is activated. The expression [bold]sh.Name = "Timesheet"[/bold] evaluates correctly to TRUE, and the debug.print line works, but the scrollbars are not removed, and the fullscreen does not activate. Oddly, if I place a breakpoint on any of those four lines, execution does not break.
The second odd thing occurs if I remove the comment marker before the MsgBox line. Selecting any sheet except timesheet, the Msgbox appears *after* the selected sheet has been displayed. Selecting Timesheet, the Msgbox appears *before* the worksheet is displayed.
The Timesheet sheet contains some complex formulae, including some dynamic ranges, charts and linked pictures, and events trapping RightClick, DoubleClick and SelectionChange but I can't see how this would affect sheet activation. None of those events are running on sheet activation. For completeness, there is no other code running in Workbook_SheetDeactivate, or the individual sheets Activate and Deactivate events.
If anyone can cast light on this mysterious oddity, I would be very grateful!
Cheers in advance,
Andy.
-------
The joke cannot be found
[sup]The funny quote you are looking for might have been removed, had its name changed, or is temporarily unavailable.[/sup]