[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Drawig Freeform shapes using VBA

Posted on 2007-10-03
Medium Priority
Last Modified: 2008-01-09
I created a Freeform shape while recording a macro. When I try to use that macro I often run into an error depending on the values used.
In the code below I have two parts. The first is the lines recorded and it works fine. The second part is with my values but it gives an error.

Can someone explain the error and propose a remedy?


Sub Fform()
    With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, 4804.5, 117932.25)
        .AddNodes msoSegmentLine, msoEditingAuto, 4742.25, 117978#
        .AddNodes msoSegmentLine, msoEditingAuto, 4747.5, 118057.5
        .AddNodes msoSegmentLine, msoEditingAuto, 4904.25, 118102.5
        .AddNodes msoSegmentLine, msoEditingAuto, 4956.75, 118044#
    End With
    With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, 6979.297118, 7097.833484)
        .AddNodes msoSegmentLine, msoEditingAuto, 6980.243934, 7097.982595
        .AddNodes msoSegmentLine, msoEditingAuto, 6979.947016, 7095.819007
    End With
End Sub
Question by:Saqib Husain, Syed
  • 3
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 20010169
Your horizontal positions are off the sheet.

LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 20010193
Nope. I was wrong. The problem is you are using values with too many decimal positions. Cut them down to two decimals or no decimals and you will have better luck.

LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 20010215
I dont think so, Kevin.
Try this

    With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, 6979.297118, 7097.833484)
        .AddNodes msoSegmentLine, msoEditingAuto, 7980.243934, 7097.982595
        .AddNodes msoSegmentLine, msoEditingAuto, 7979.947016, 7095.819007
    End With
LVL 81

Accepted Solution

zorvek (Kevin Jones) earned 2000 total points
ID: 20010299
You're correct. It didn't sound right when I posted it but it was the only thing that made sense.

It looks like the points are too close together. If I move the second one a point to the left or right it works.

LVL 17

Expert Comment

ID: 20010314

I agree with Kevin.  I played with it a bit and when I moved the nodes farther apart it worked fine.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question