'### Constantes à adapter ###
Private Const HAUT As Long = 300
Private Const GAUCHE As Long = 700
'############################
Private Declare Function FindWindow& Lib "User32" Alias "FindWindowA" ( _
ByVal lpClassName As String, ByVal lpWindowName As String)
Private Declare Function MoveWindow& Lib "User32" ( _
ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long)
Private Declare Function GetWindowRect& Lib "User32" ( _
ByVal hwnd As Long, lpRect As RECT)
Private Declare Sub SetWindowPos Lib "User32" ( _
ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Sub LanceCalculatrice()
Dim ret&
Dim hdl&
Dim Rec As RECT
ret& = Shell("C:\WINDOWS\system32\calc.EXE", 1)
hdl& = FindWindow(vbNullString, "Calculatrice")
GetWindowRect hdl&, Rec
MoveWindow hdl&, GAUCHE, HAUT, Rec.Right - Rec.Left, Rec.Bottom - Rec.Top, 1
'--- Pour laisser la calculatrice au 1er plan tout en ayant accès à la feuille Excel mettre ---
'--- HWND_TOPMOST pour le second paramètre SINON mettre HWND_NOTOPMOST OU flaguer l'instruction ---
SetWindowPos hdl&, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
'-------------------------------------------------------------------------------------------------
End Sub