Modifier un texte dans un Shape

Résolu
CerberusPau Messages postés 377 Date d'inscription lundi 3 avril 2006 Statut Membre Dernière intervention 22 août 2018 - 7 nov. 2010 à 16:37
jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 - 10 nov. 2010 à 18:46
Bonjour à tous,

Qulqu'un sait-il comment on peut modifier un texte dans un Shape enVBA ?

Les codes suivants ne fonctionnent pas :
ActiveSheet.Shapes(1).Select
ActiveSheet.Shapes(1).Text = "Texte"
  'Ou encore
ActiveSheet.Shapes(1).TextFrame.Characters.Text = "Texte"


Je crois qu'il existe une possibilité en passant par un ChartObject :
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Shapes(1).TextFrame.Characters.Text = "Texte"

Mais je ne sais pas comment faire exactement ...

Merci de votre aide

Cordialement
Rataxes64

1 réponse

jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 344
10 nov. 2010 à 18:46
Bonjour,
en passant par l'enregistreur de macro j'ai obtenu ceci:

    ActiveSheet.Shapes("Oval 3").Select
    Selection.Characters.Text = "ceci est le nouveau texte"
    With Selection.Characters(Start:=1, Length:=26).Font
        .Name = "Calibri"
        .FontStyle = "Normal"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 1
    End With
    Range("H18").Select
    ActiveSheet.Shapes("Oval 3").Select
    ActiveSheet.Shapes("Oval 3").Select
    Selection.Characters.Text = "texte modifié"
    With Selection.Characters(Start:=1, Length:=13).Font
        .Name = "Calibri"
        .FontStyle = "Normal"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 1
    End With



en espérant que cela pourra t'aider.

Cordialement,
Jordane,
______________________________________________________
Règles du forum à lire avant de poster une question : ICI
1
Rejoignez-nous