Option Explicit
Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
' Public Variables
Dim mlTime As Long
Public mlTimerID As Long
Public mbTimerState As Boolean
Sub TimerOn()
mlTime = 2
If mbTimerState = False Then
mlTimerID = SetTheTimer
End If
If mlTimerID = 0 Then
MsgBox "Unable to create the timer", vbCritical + vbOKOnly, "Error"
Exit Sub
End If
mbTimerState = True
End Sub
Sub TimerOff()
If mbTimerState = True Then
mlTimerID = KillTimer(0, mlTimerID)
If mlTimerID = 0 Then
MsgBox "Unable to stop the timer", vbCritical + vbOKOnly, "Error"
End If
mbTimerState = False
End If
End Sub
Function SetTheTimer()
SetTheTimer = SetTimer(0, 0, mlTime * 1000, AddressOf ClosePrintPreview)
End Function
Sub TimedSub()
MsgBox "verify"
End Sub
Sub ShowStarringAllCharts() ' print preview as slide show and with conditions that a chart sheet can contain chart objects
Dim Sht As Object
Dim ChtObj As ChartObject
Application.DisplayFullScreen = True
Application.ScreenUpdating = False
TimerOn
For Each Sht In ActiveWorkbook.Sheets
If TypeName(Sht) = "Chart" Then
Sht.PrintPreview
End If
For Each ChtObj In Sht.ChartObjects
ChtObj.Chart.PrintPreview
Next ChtObj
Next
TimerOff
Application.DisplayFullScreen = False
End Sub
Sub ClosePrintPreview()
SendKeys "{ESC}"
End Sub