Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Aligner barre d'outils sur cellule

1 réponse
Avatar
garnote
Bonjour tout le monde,

J'ai les «NameLocal» des barres d'outils de A1 à A42
et les «Name» de ces mêmes barres de B1 à B42.
J'ai aussi un rectangle.
J'utilise la macro suivante pour faire apparaître chaque
barre d'outils. Mais voilà, je voudrais que la barre d'outils
apparaisse au même endroit ( Left et Top ) que mon rectangle.
Est-ce possible ?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Target.Column = 1 And Target.Row < 43 Then
b1 = Target(1, 2)
b2 = Target.Offset(-1, 1)
b3 = Target.Offset(1, 1)
L = Target(1, 3).Left
T = Target(1, 3).Top
With Shapes("Rectangle 2")
.Left = L
.Top = T
End With
CommandBars(b2).Visible = False
CommandBars(b3).Visible = False
With CommandBars(b1)
.Visible = True
.Left = L ' ???
.Top = T ' ???
End With
End If
End Sub

J'ai obtenu ma liste par cette macro :

Sub NomsBarres()
Dim x As CommandBar
Application.ScreenUpdating = False
Sheets.Add
L = 1
For Each x In Application.CommandBars
If x.Type = msoBarTypeNormal Then
Cells(L, 1) = x.NameLocal
Cells(L, 2) = x.Name
L = L + 1
End If
Next x
Set ici = ActiveSheet.UsedRange
ici.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Columns("A:B").EntireColumn.AutoFit
End Sub

Merci,

Serge

1 réponse

Avatar
Denis Michon
Bonjour Garnote,

En adaptant le nom de la feuille et le nom de ton objet (rectangle)...

With worksheets("Feuil1")
T = .shapes("Rectangle 1").top
L = .shapes("Rectangle 1").Left
End with

With CommandBars(b1)
.Visible = True
.Left = L
.Top = T
End With


Est-ce que cela fonctionne ?


Salutations!


"garnote" a écrit dans le message de news:toyib.157754$
Bonjour tout le monde,

J'ai les «NameLocal» des barres d'outils de A1 à A42
et les «Name» de ces mêmes barres de B1 à B42.
J'ai aussi un rectangle.
J'utilise la macro suivante pour faire apparaître chaque
barre d'outils. Mais voilà, je voudrais que la barre d'outils
apparaisse au même endroit ( Left et Top ) que mon rectangle.
Est-ce possible ?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Target.Column = 1 And Target.Row < 43 Then
b1 = Target(1, 2)
b2 = Target.Offset(-1, 1)
b3 = Target.Offset(1, 1)
L = Target(1, 3).Left
T = Target(1, 3).Top
With Shapes("Rectangle 2")
.Left = L
.Top = T
End With
CommandBars(b2).Visible = False
CommandBars(b3).Visible = False
With CommandBars(b1)
.Visible = True
.Left = L ' ???
.Top = T ' ???
End With
End If
End Sub

J'ai obtenu ma liste par cette macro :

Sub NomsBarres()
Dim x As CommandBar
Application.ScreenUpdating = False
Sheets.Add
L = 1
For Each x In Application.CommandBars
If x.Type = msoBarTypeNormal Then
Cells(L, 1) = x.NameLocal
Cells(L, 2) = x.Name
L = L + 1
End If
Next x
Set ici = ActiveSheet.UsedRange
ici.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom
Columns("A:B").EntireColumn.AutoFit
End Sub

Merci,

Serge