Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Drawing a Curve programmatically
Hiya
I'm trying to draw around a circle using a freeform drawing but I can seem to figure out the drawing of the curve - This is what I have so far: Sub Macro8() Set ws = ThisWorkbook.Worksheet("Sheet1") x = 1200 y = 100 SV = 100 'Draws the Circle With ws.Shapes.AddShape(msoShapeOval, x, y, SV, SV) .Fill.ForeColor.SchemeColor = 2 .Line.Visible = msoFalse End With 'Draws the Segement of the Circle With ws.Shapes.BuildFreeform(msoEditingAuto, x + SV / 2, y) .AddNodes msoSegmentLine, msoEditingAuto, x + SV / 2, y + SV / 2 .AddNodes msoSegmentLine, msoEditingAuto, x, y + SV / 2 'Part of the program I'm struggling with .AddNodes msoSegmentLinem, msoEditingCorner, x + SV / 4, y + SV / 4, x + (SV / 4) * 2, y + (SV / 4) * 2, x + SV / 2, y .ConvertToShape.Select End With End Sub The part I'm having trouble with is ..AddNodes msoSegmentLinem, msoEditingCorner, x + SV / 4, y + SV / 4, x + (SV / 4) * 2, y + (SV / 4) * 2, x + SV / 2, y I can draw a straight line back but I want to make it curved and it keeps bringing up and error about a value being out of range when I get to this line - anyone have any ideas. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Drawing a Curve programmatically
one typo and change msoSegmentLINE to msoSegmentCurve
This tested OK: Sub Macro8() Dim WS As Worksheet Dim X As Long Dim y As Long Dim SV As Long Set WS = ThisWorkbook.Worksheets("Sheet1") X = 1200 y = 100 SV = 100 'Draws the Circle With WS.Shapes.AddShape(msoShapeOval, X, y, SV, SV) .Fill.ForeColor.SchemeColor = 2 .Line.Visible = msoFalse End With 'Draws the Segement of the Circle With WS.Shapes.BuildFreeform(msoEditingAuto, X + SV / 2, y) .AddNodes msoSegmentLine, msoEditingAuto, X + SV / 2, y + SV / 2 .AddNodes msoSegmentLine, msoEditingAuto, X, y + SV / 2 'Part of the program I'm struggling with .AddNodes msoSegmentCurve, msoEditingCorner, X + SV / 4, y + SV / 4, X + (SV / 4) * 2, y + (SV / 4) * 2, X + SV / 2, y .ConvertToShape.Select End With End Sub Patrick Molloy Microsoft Excel MVP -----Original Message----- Hiya I'm trying to draw around a circle using a freeform drawing but I can seem to figure out the drawing of the curve - This is what I have so far: Sub Macro8() Set ws = ThisWorkbook.Worksheet("Sheet1") x = 1200 y = 100 SV = 100 'Draws the Circle With ws.Shapes.AddShape(msoShapeOval, x, y, SV, SV) .Fill.ForeColor.SchemeColor = 2 .Line.Visible = msoFalse End With 'Draws the Segement of the Circle With ws.Shapes.BuildFreeform(msoEditingAuto, x + SV / 2, y) .AddNodes msoSegmentLine, msoEditingAuto, x + SV / 2, y + SV / 2 .AddNodes msoSegmentLine, msoEditingAuto, x, y + SV / 2 'Part of the program I'm struggling with .AddNodes msoSegmentLinem, msoEditingCorner, x + SV / 4, y + SV / 4, x + (SV / 4) * 2, y + (SV / 4) * 2, x + SV / 2, y .ConvertToShape.Select End With End Sub The part I'm having trouble with is ..AddNodes msoSegmentLinem, msoEditingCorner, x + SV / 4, y + SV / 4, x + (SV / 4) * 2, y + (SV / 4) * 2, x + SV / 2, y I can draw a straight line back but I want to make it curved and it keeps bringing up and error about a value being out of range when I get to this line - anyone have any ideas. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Drawing a Quadratic Curve in Excel | Charts and Charting in Excel | |||
curve fitting a charging capacitor type curve | Excel Discussion (Misc queries) | |||
Programmatically Add Reference` | Excel Programming | |||
Programmatically Add Reference` | Excel Programming | |||
Can i set a reference programmatically? | Excel Programming |