Hi,
I think it is not possible, at least I didn't find a way to do it.
Following code reads the prosition of the cursor, hide it for the given amount of time and place it back where it was.
Run ActivateMain to activate Main, giving some time to move to the Excel sheet.
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
#If VBA7 Then
Private Declare PtrSafe Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
#Else
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
#End If
Sub Main()
Dim CurPos As POINTAPI
Dim intStopSec As Integer
GetCursorPos CurPos
intStopSec = Application.InputBox(Prompt:="Stop cursor movement", Default:=30)
ShowCursor False
Application.Wait Now + TimeSerial(0, 0, intStopSec)
SetCursorPos CurPos.x, CurPos.y
ShowCursor True
End Sub
Sub ActivateMain()
Application.OnTime Now + TimeValue("00:00:05"), "Main"
End Sub