Click here to Skip to main content
15,877,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello My Name IS Eric Nice To Meet you all ..... 

I have a simple Question .I would like to name a shape in excel upon its 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 parent name "Jimmy". I believe it has to do with a "event Handler " but i am way to new to excel to determine exactly what i need ...........Please Help Someone ! code attached below ......... 
Like "Jimmy1" "Jimmy2" etc 

VB
Sub Neave_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

Thank you in advance Eric Maxfield
Posted

1 solution

VB
Dim lineNumber As Integer

Sub Neave_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)
lineNumber = lineNumber + 1
Selection.Name = "Jimmy" & lineNumber
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900