PDA

View Full Version : [SOLVED] Naming A Shape and Connector Line After Its Creation"runtime" Excel VBA



emax79
12-13-2013, 09:16 AM
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

Kenneth Hobs
12-13-2013, 11:04 AM
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

emax79
12-13-2013, 11:19 AM
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