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

x
?
Solved

Drawig Freeform shapes using VBA

Posted on 2007-10-03
5
Medium Priority
?
1,206 Views
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?

Saqib

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#
        .ConvertToShape.Select
    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
        .ConvertToShape.Select
    End With
End Sub
0
Comment
Question by:Saqib Husain, Syed
  • 3
5 Comments
 
LVL 81

Expert Comment

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

Kevin
0
 
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.

Kevin
0
 
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
        .ConvertToShape.Select
    End With
0
 
LVL 81

Accepted Solution

by:
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.

Kevin
0
 
LVL 17

Expert Comment

by:LoNeRaVeR9
ID: 20010314
ssagibh:

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

Jaes
0

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