XL 2016 VBA Centrer un Shape dans l'ActiveWindow

Dudu2

XLDnaute Barbatruc
Bonjour,

J'y perds mon latin et mon VBA.
Je n'arrive pas à centrer une Shape dans l'ActiveWindow. Je n'y comprends rien !
 

Pièces jointes

  • ShowShape.xlsm
    31.9 KB · Affichages: 0

patricktoulon

XLDnaute Barbatruc
Bonjour @Dudu2
ceci fonctionne aussi et c'est même plus précis
VB:
  'Centrer la Shape en largeur
    If LeftPoints = xlNone Then
        With Application
            Shape.Left = .Left + (.UsableWidth - Shape.Width) / 2
        End With
    Else
        Shape.Left = LeftPoints
    End If
  
    'Centrer la Shape en hauteur
    If TopPoints = xlNone Then
        With Application
            Shape.Top = .Top + (.UsableHeight - Shape.Height) / 2
        End With
    Else
        Shape.Top = TopPoints
    End If
petite demo
VB:
Sub Bouton6_Cliquer()
Dim rng As Range, t As String
Set rng = ActiveWindow.VisibleRange
t = "viblerange :" & rng.Address(0, 0) & " : " & rng.Width & " points" & vbCr & vbCr
t = t & " si tu regarde bien  la colonne " & rng.Cells(rng.Cells.Count).EntireColumn.Address(0, 0) & vbCr
t = t & " tu verra quelle n'est pas completement visible " & vbCr & vbCr
t = t & " usableWidth de l'application :" & Application.UsableWidth & " points"
MsgBox t
End Sub
 
Dernière édition:

Discussions similaires

Réponses
30
Affichages
1 K

Statistiques des forums

Discussions
313 769
Messages
2 102 234
Membres
108 181
dernier inscrit
Chr1sD