'### Constante à adapter ###
Const MA_FEUILLE As String = "test" 'Adapter le nom de la feuille
'###########################
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Demo()
Dim S As Worksheet
Dim k&
Dim i&
Dim EtatWindow
EtatWindow = Array(xlNormal, xlMaximized)
On Error Resume Next
Set S = Sheets(MA_FEUILLE)
If Err <> 0 Then
MsgBox "La feuille ''" & MA_FEUILLE & "'' est introuvable."
Exit Sub
End If
On Error GoTo 0
S.Activate
For k& = LBound(EtatWindow) To UBound(EtatWindow)
Application.WindowState = EtatWindow(k&)
For i& = 50 To 200 Step 25
Application.ScreenUpdating = False
ActiveWindow.Zoom = i&
[a1].Select
Call CentrerHorizontalShapesAvecZoom(S)
Call CentrerVerticalShapesAvecZoom(S)
Application.ScreenUpdating = True
DoEvents
Sleep 400
Next i&
Next k&
End Sub
Sub Direct()
Call CentrerHorizontalShapesAvecZoom(Sheets(MA_FEUILLE))
Call CentrerVerticalShapesAvecZoom(Sheets(MA_FEUILLE))
End Sub
Sub CentrerHorizontalShapesAvecZoom(S As Worksheet)
Dim SH As Shape
Dim WindowWidth As Double
WindowWidth = ActiveWindow.UsableWidth * (100 / ActiveWindow.Zoom) - 18
For Each SH In S.Shapes
SH.Left = ((WindowWidth - SH.Width) / 2) - 1
Next SH
End Sub
Sub CentrerVerticalShapesAvecZoom(S As Worksheet)
Dim SH As Shape
Dim WindowHeight As Double
WindowHeight = ActiveWindow.UsableHeight * (100 / ActiveWindow.Zoom) - 18
For Each SH In S.Shapes
SH.Top = ((WindowHeight - SH.Height) / 2) - 1
Next SH
End Sub