With ActiveSheet.Shapes("shape1")
.TextFrame.Characters.Text = "Bonsoir"
.TextFrame.Characters.Font.Size = 8
.TextFrame.Characters.Font.Name = "Comic Sans Ms"
End With
Private Sub CommandButton1_Click()
Dim iTop As Single, ileft As Single
Dim iCata As String
Dim iTexte(2) As String
Dim NomTG_Texte As String
Dim i As Long
Dim NbCar(2) As Long
NomTG_Texte = Application.Caller
iCata = "CATA_" & Mid(Application.Caller, 4)
iTexte(1) = Trim(TextBox1)
iTexte(2) = Trim(TextBox4)
NbCar(2) = Len(iTexte(2))
NbCar(1) = Len(iTexte(1))
If NbCar(2) > 0 Then
ActiveSheet.Shapes(NomTG_Texte).TextFrame.Characters.Text = Trim(iTexte(1)) & vbCrLf & "[" & Trim(iTexte(2)) & "]"
'ActiveSheet.Shapes(NomTG_Texte).TextFrame.AutoSize = True
Else
ActiveSheet.Shapes(NomTG_Texte).TextFrame.Characters.Text = Trim(iTexte(1))
ActiveSheet.Shapes(NomTG_Texte).TextFrame.Characters.Font.ColorIndex = 1
End If
If NbCar(2) > 0 Then
ActiveSheet.Shapes(NomTG_Texte).TextFrame.Characters(Start:=1, Length:=NbCar(1)).Font.ColorIndex = 1
ActiveSheet.Shapes(NomTG_Texte).TextFrame.Characters(Start:=NbCar(1) + 1, Length:=NbCar(2) + 10).Font.ColorIndex = 3
End If
If CheckBox1 = True Then
iTop = ActiveSheet.Shapes(NomTG_Texte).Top
ileft = ActiveSheet.Shapes(NomTG_Texte).Left
ActiveSheet.Shapes(iCata).Visible = True
ActiveSheet.Shapes(iCata).Top = iTop - 5
ActiveSheet.Shapes(iCata).Left = ileft - 5
Else
ActiveSheet.Shapes(iCata).Visible = False
End If
If CheckBox2 = True Then
ActiveSheet.Shapes(Application.Caller).DrawingObject.Interior.ColorIndex = 15
Else
ActiveSheet.Shapes(Application.Caller).DrawingObject.Interior.ColorIndex = 2
End If
'######### ajout pmo
Dim SH As Shape
Dim SH_pmo As Shape
Dim W As Double
Dim H As Double
'---
Set SH = ActiveSheet.Shapes(Application.Caller)
W = SH.Width
H = SH.Height
'--- Création d'un object Rectangle temporaire ---
Application.ScreenUpdating = False
Set SH_pmo = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 0, 0, W, H)
SH_pmo.TextEffect.Text = SH.TextEffect.Text
SH_pmo.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
'--- Détermine la taille adéquate de la police ---
Do
SH_pmo.TextEffect.FontSize = SH_pmo.TextEffect.FontSize - 1
SH_pmo.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
Loop Until SH_pmo.Width <= W And SH_pmo.Height <= H
SH.TextEffect.FontSize = SH_pmo.TextEffect.FontSize
SH_pmo.Delete
Application.ScreenUpdating = True
'#########
Unload Me
End Sub
Sub testShapes()
Dim S As Worksheet
Dim SH As Shape
Dim i&
'---
Set S = Sheets.Add(After:=Sheets(Sheets.Count))
For Each SH In Sheets("POS PENETRANTE").Shapes
i& = i& + 1
S.Cells(i&, 1) = SH.Name
S.Cells(i&, 2) = SH.OnAction
Next SH
End Sub
'Private Sub UserForm_initialize()
'Dim iCata As String, i As Long
'Dim iTexte As String
'Dim NomTG_Texte As String
'Dim iT() As String
'TextBox3 = Application.Caller
'iCata = "CATA_" & Mid(Application.Caller, 4)
'iT() = Split(ActiveSheet.Shapes(Application.Caller).TextFrame.Characters.Text, "[")
'If InStr(1, ActiveSheet.Shapes(Application.Caller).TextFrame.Characters.Text, "[") > 0 Then
' TextBox1 = Replace(Trim(iT(0)), Chr(10), "")
' TextBox4 = Replace(Trim(iT(1)), Chr(10), "")
' TextBox4 = Replace(Trim(iT(1)), "]", "")
'Else
' TextBox1 = Replace(Trim(ActiveSheet.Shapes(Application.Caller).TextFrame.Characters.Text), Chr(10), "")
'
'End If
'If ActiveSheet.Shapes(iCata).Visible = True Then
' CheckBox1 = True
'Else
' CheckBox1 = False
'End If
'If ActiveSheet.Shapes(Application.Caller).DrawingObject.Interior.ColorIndex = 15 Then
' CheckBox2 = True
'Else
' CheckBox2 = False
'End If
'End Sub
Private Sub UserForm_initialize()
Dim iCata As String, i As Long
Dim iTexte As String
Dim NomTG_Texte As String
Dim iT() As String
Dim SH As Shape
'---
Set SH = ActiveSheet.Shapes(Application.Caller)
TextBox3 = SH.Name
iCata = "CATA_" & Mid(SH.Name, 4)
iT() = Split(SH.TextFrame.Characters.Text, "[")
If InStr(1, SH.TextFrame.Characters.Text, "[") > 0 Then
TextBox1 = Replace(Trim(iT(0)), Chr(10), "")
TextBox4 = Replace(Trim(iT(1)), Chr(10), "")
TextBox4 = Replace(Trim(iT(1)), "]", "")
Else
TextBox1 = Replace(Trim(SH.TextFrame.Characters.Text), Chr(10), "")
End If
If ActiveSheet.Shapes(iCata).Visible = True Then
CheckBox1 = True
Else
CheckBox1 = False
End If
If SH.DrawingObject.Interior.ColorIndex = 15 Then
CheckBox2 = True
Else
CheckBox2 = False
End If
End Sub