Excel VBA Line Shape (Ver 2003) and (Ver2019)

SOMESH JHAWAR 1 Reputation point


In earlier version of VBA Excel (2003), the nodes property exist for Line shapes.
So, to get the start and end point's co-ordinates of any shape(created earlier), we can get it from "Shape.Nodes(1).points" and "Shape.Nodes(2).points.

But in new version (2019), there is no nodes for line shape.
How to get the co-ordinates of line now?

In my following Example, I created 2 lines:
ActiveSheet.Shapes.AddLine(50,50,200,200) (looks like "\")
ActiveSheet.Shapes.AddLine(50,200,200,50) (looks like "/")

Now for both the shapes, the output of shape.left, .top, .width, .height , .horizontalFlip, .VerticalFlip are same.
So , now how we can get the co-ordinates for both the lines?


Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,527 questions
{count} votes

2 answers

Sort by: Most helpful
  1. SOMESH JHAWAR 1 Reputation point

    I am posting a Table image, which can help to understand the orientation of line, by the value of Horizontal and Vertical Flip.
    In my Question , i get same result in Flips value of both lines because of copy-paste (taking shape 1 flip value, in place of shape 2 flip values) in output.

    Short form used in this tables are :
    Column from->To : T=Top, L=Left, B=Bottom, R= Right
    Column X1, first parameter in addline method
    column Y1, second parameter in addline method
    Column X2,third parameter in addline method
    Column Y2, forth parameter in addline method

    Column Hf= HorizontalFlip value of Shape
    column Vf=VerticalFlip value of Shape

    So, i need to write some more code, to get the X1,Y1 and X2,Y2 for any line, by using Hf and Vf values of Shape.
    I hope , it will help to re-use my Code of 2003 version in , new excel version.


    My, suggestion to Microsoft, Please keep a logbook, in which you can keep a change details from your previous version to new version.
    Also keep a turnaround solution detail, so people can use there work in advance version also.

    0 comments No comments

  2. Viki Ji_MSFT 4,421 Reputation points

    As the tag office-excel-itpro focuses on general issues about Excel client, but your issue is more related to code, to better help you, I would suggest you post a new question on the following forum.

    Office developer community

    Thanks for your understanding.

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments