Consulting

Results 1 to 3 of 3

Thread: Naming A Shape and Connector Line After Its Creation"runtime" Excel VBA

  1. #1
    VBAX Regular
    Joined
    Dec 2013
    Posts
    18
    Location

    Naming A Shape and Connector Line After Its Creation"runtime" Excel VBA

    HelloMy Name IS Eric Nice To Meet you all .....

    Ihave a simple Question .I would like to name a shape in excel uponits creation ...... I Can name the"line" in the macro....But I would like every other line created after its Name to be"numerated or given a unique identifier while keeping its parentname "Jimmy". I believe it has to do with a "eventHandler " but i am way to new to excel to determine exactly whati need ...........Please Help Someone ! code attached below.........

    Like"Jimmy1" "Jimmy2" etc


    SubNave_Click()
    ActiveSheet.Shapes.AddConnector(msoConnectorStraight,400, 150, 800,150).Select
    Selection.ShapeRange.Line.BeginArrowheadLength =msoArrowheadShort
    Selection.ShapeRange.Line.BeginArrowheadStyle =msoArrowheadStealth
    Selection.ShapeRange.Line.BeginArrowheadWidth= msoArrowheadNarrow
    Selection.ShapeRange.Line.EndArrowheadLength= msoArrowheadShort
    Selection.ShapeRange.Line.EndArrowheadStyle =msoArrowheadStealth
    Selection.ShapeRange.Line.EndArrowheadWidth =msoArrowheadNarrow
    Selection.ShapeRange.Line.Weight =2.5
    Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0,255)
    Selection.Name = "Jimmy"
    End Sub
    
    

    Thankyou in advance Eric Maxfield

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!
    Sub Nave_Click()
      Dim s As Shape
      Set s = ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 400, 150, 800, 150)
      s.Select
      With Selection
        .ShapeRange.Line.BeginArrowheadLength = msoArrowheadShort
        .ShapeRange.Line.BeginArrowheadStyle = msoArrowheadStealth
        .ShapeRange.Line.BeginArrowheadWidth = msoArrowheadNarrow
        .ShapeRange.Line.EndArrowheadLength = msoArrowheadShort
        .ShapeRange.Line.EndArrowheadStyle = msoArrowheadStealth
        .ShapeRange.Line.EndArrowheadWidth = msoArrowheadNarrow
        .ShapeRange.Line.Weight = 2.5
        .ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 255)
        .Name = "Jimmy" & ActiveSheet.Shapes.Count
      End With
    End Sub

  3. #3
    VBAX Regular
    Joined
    Dec 2013
    Posts
    18
    Location

    Wow Thank You So Much ! you saved me hours and hours ! I just a rookie .... Tytytytyt

    Quote Originally Posted by Kenneth Hobs View Post
    Welcome to the forum!
    Sub Nave_Click()
      Dim s As Shape
      Set s = ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 400, 150, 800, 150)
      s.Select
      With Selection
        .ShapeRange.Line.BeginArrowheadLength = msoArrowheadShort
        .ShapeRange.Line.BeginArrowheadStyle = msoArrowheadStealth
        .ShapeRange.Line.BeginArrowheadWidth = msoArrowheadNarrow
        .ShapeRange.Line.EndArrowheadLength = msoArrowheadShort
        .ShapeRange.Line.EndArrowheadStyle = msoArrowheadStealth
        .ShapeRange.Line.EndArrowheadWidth = msoArrowheadNarrow
        .ShapeRange.Line.Weight = 2.5
        .ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 255)
        .Name = "Jimmy" & ActiveSheet.Shapes.Count
      End With
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •