Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing a Quadratic Curve in Excel Xero Charts and Charting in Excel 3 June 12th 06 01:09 PM
curve fitting a charging capacitor type curve mcgradys Excel Discussion (Misc queries) 4 November 15th 05 12:46 PM
Programmatically Add Reference` keepitcool Excel Programming 1 September 16th 03 05:30 PM
Programmatically Add Reference` Jean-Paul Viel Excel Programming 0 September 16th 03 02:23 PM
Can i set a reference programmatically? Tom Ogilvy Excel Programming 1 August 19th 03 04:24 PM


All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"