VBA editing points of polyline

remko_g

New Member
Joined
Sep 11, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

With the following code, I draw a hook. Manually I can chamfer the corner. But is this also possible with VBA-code?

VBA Code:
Sub mrExcel()

    Dim myDocument
    Set myDocument = Worksheets(1)

    Dim cellLeft, cellTop As Double
    
    cellLeft = Selection.Left
    cellTop = Selection.Top

    Dim delta As Integer
    delta = 8

    Dim corner As Variant
    
    corner = Array( _
        Array(cellLeft + 3, cellTop + 29), _
        Array(cellLeft + 3, cellTop + 9 + delta), _
        Array(cellLeft + 3 + delta, cellTop + 9), _
        Array(cellLeft + 79, cellTop + 9) _
    )

    Dim polylineshape As Shape
    Set polylineshape = myDocument.Shapes.AddPolyline((corner))

    With polylineshape.Line
        .Weight = 0.75
        .ForeColor.RGB = RGB(0, 0, 0)
    End With

End Sub

Draw polyline using VBA

1726060267195.png


Chamfer the corner

1726060321006.png
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
As you probably noticed you cannot record a macro while manually doing this. VBA Help also isn't too helpful here. I think you need this method: ShapeNodes.SetSegmentType method (Excel).
Afte that, you'll have to find the right point to move (changing the segment type adds/removes points!) and then you need polylineshape.Nodes.SetPosition to change its position
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,522
Messages
6,160,308
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top