
'// ScreenSaver routine for Embeded Object
Option Explicit
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function BlockInput Lib "user32" ( _
ByVal fBlock As Long) As Long
Private Declare Sub Sleep Lib "kernel32" ( _
ByVal dwMilliseconds As Long)
Private Const WM_SYSCOMMAND As Long = &H112
Private Const SC_SCREENSAVE As Long = &HF140
Sub Run_Embeded_SS()
Dim ScrnS As Object
'// Show ScreenSaver = Shapes("Object 8")
'// Note 8 as OleObject index, next one will be 9!
Application.DisplayAlerts = False
Set ScrnS = Sheet1.OLEObjects("Object 8")
ScrnS.Verb
Set ScrnS = Nothing
Application.DisplayAlerts = True
BlockInputs 10
End Sub
Sub BlockInputs(tmDelaySecs As Long)
DoEvents
'// Disable any inputs mouse/keyboard
BlockInput True
'// pause tmDelaySecs * 1000 = seconds before unblocking it
Sleep tmDelaySecs * 1000
'// Enable inputs mouse/keyboard
BlockInput False
End Sub