How robust are the drawing tools in MS Word?
I need to draw circles and divide their circumference arcs into portions. I'm considering Word because it gives me printing options that other apps I have do not.
I figured out how to create circles with diameters I want, but I haven't figured out how to divide them into sections. Of course, I could print them and use a protractor and pencil to draw them, but I wondered if I could do the whole thing in Word. I also looked at pie charts but couldn't discover how to define the segments of the chart.
This is obviously a case of making the world a nail because the only tool I have is a hammer, but I thought I'd ask anyway.
How Robust?
-
- UraniumLounger
- Posts: 9589
- Joined: 13 Feb 2010, 01:27
- Location: Deep in the Heart of Texas
How Robust?
Bob's yer Uncle
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs
(1/2)(1+√5) |
-
- Administrator
- Posts: 79561
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlutoniumLounger
- Posts: 16307
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: How Robust?
Hi Bob. If you have MSWord then you probably have MSOffice which means that you have MSExcel as well.
I would approach this as specifying your problem, and then the solution.
Problem: Draw circles of a specified diameter, divided into segments (pie-like) based on a percentage of the circumference.
If we wrote that out as a function, you would want to ask for:-
Code: Select all
DrawSegments(20, 17, 13, 18, 10, 4, 5, 17, 16)
Is that close to what you want?
Your point about Word being good for printing comes right at the end of the solution; as long as you can get an appropriate diagram INTO word, then the printing is the easy part. But (in a way) you don't care hoe you get the diagram, as long as you can get it, whether it is in Excel or in Word.
Cheers, Chris
If it isn't one thing it's another, and very often both. E.F.Benson
-
- UraniumLounger
- Posts: 9589
- Joined: 13 Feb 2010, 01:27
- Location: Deep in the Heart of Texas
Re: How Robust?
Thanks for the responses.
Yes, Hans, I want equal segments.
I found that I can draw a circle and give it the dimensions I want, then print it; however that doesn't give me the segments I need. I saw that there is a pie chart and experimented with it. I can get the segments I need but cannot make the diameter the length I need with it. Despite there being size controls, I don't seem to be able to make them work correctly.
Yes, Hans, I want equal segments.
I found that I can draw a circle and give it the dimensions I want, then print it; however that doesn't give me the segments I need. I saw that there is a pie chart and experimented with it. I can get the segments I need but cannot make the diameter the length I need with it. Despite there being size controls, I don't seem to be able to make them work correctly.
Bob's yer Uncle
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs
(1/2)(1+√5) |
-
- Administrator
- Posts: 79561
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How Robust?
You might create a pie chart with the segments that you want.
Also create a horizontal line - you can specify its length.
With a bit of trial and error, you should be able to resize the pie chart to match the line.
You can discard the line when you're done.
Also create a horizontal line - you can specify its length.
With a bit of trial and error, you should be able to resize the pie chart to match the line.
You can discard the line when you're done.
Best wishes,
Hans
Hans
-
- UraniumLounger
- Posts: 9589
- Joined: 13 Feb 2010, 01:27
- Location: Deep in the Heart of Texas
Re: How Robust?
Great idea. Thanks, Hans.
Bob's yer Uncle
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs
(1/2)(1+√5) |
-
- 5StarLounger
- Posts: 641
- Joined: 27 Jun 2021, 10:46
Re: How Robust?
It can be done in excel with a pie chart and vba; just needs to deal with a couple of minor quirks of the pie chart shape ...
e.g
e.g
Code: Select all
Option Explicit
Public Sub example()
DrawSegments 10, 20, 30, 15, 5, 19, 5
End Sub
' Diameter in cms
Public Sub DrawSegments(diameter As Single, ParamArray dataarray() As Variant)
Dim chrtname As String
ActiveSheet.Shapes.AddChart2(-1, xlPie).Select ' add and make chart active
ActiveSheet.Range(Cells(1, 1), Cells(1, UBound(dataarray) + 1)).Value = dataarray ' set range to our data
ActiveChart.SetSourceData Source:=Range(Cells(1, 1), Cells(1, UBound(dataarray) + 1)) ' pie chart now uses our data
' Get rid of stuff we do not need
ActiveChart.ChartTitle.Delete
ActiveChart.Legend.Delete
' Format the pie chart to meet our requirements
chrtname = Replace(ActiveChart.Name, ActiveSheet.Name & " ", "")
ActiveSheet.Shapes(chrtname).Height = Application.CentimetersToPoints(diameter + 1) ' make shape height 1 cm bigger than required diameter of pie chart
ActiveSheet.Shapes(chrtname).Width = Application.CentimetersToPoints(diameter + 1) ' make shape width 1 cm bigger than required diameter of pie chart
ActiveSheet.Shapes(chrtname).LockAspectRatio = msoTrue
ActiveSheet.Shapes(chrtname).Fill.Visible = msoFalse
ActiveSheet.Shapes(chrtname).Line.Visible = msoFalse
'Resize plotarea to required diameter of pie chart
ActiveChart.PlotArea.Select
With Selection
.Width = Application.CentimetersToPoints(diameter)
.Height = Application.CentimetersToPoints(diameter)
End With
' Just an example of customising a segment
With ActiveChart.FullSeriesCollection(1).Points(1).Format.Fill
.ForeColor.RGB = RGB(255, 0, 0)
End With
End Sub
-
- 5StarLounger
- Posts: 641
- Joined: 27 Jun 2021, 10:46
Re: How Robust?
And here's a pure Word example
Code: Select all
Sub doit()
DrawCircleSegments 10, -90, 17, 13, 18, 10, 4, 5, 17, 16
End Sub
Sub DrawCircleSegments(diameter As Double, startangle As Double, ParamArray segments() As Variant)
Dim total As Double
Dim lp As Long
Dim radius As Single
Dim centerX As Single
Dim centerY As Single
Dim pieShape As Shape
Dim doc As Document
Set doc = ActiveDocument
For lp = 0 To UBound(segments)
total = total + segments(lp)
Next
For lp = 0 To UBound(segments)
segments(lp) = segments(lp) * 360 / total
Next
' Set the radius and center of the circle
radius = Application.CentimetersToPoints(diameter / 2) '100 ' Radius of the circle
centerX = 200 ' X position of the center in points
centerY = 200 ' Y position of the center in points
' for each segment create a pie shape and then adjust the angles
For lp = 0 To UBound(segments)
Set pieShape = doc.Shapes.AddShape(msoShapePie, centerX - radius, centerY - radius, radius * 2, radius * 2)
' Set the angles to create a segment (in degrees)
pieShape.Adjustments.Item(1) = startangle ' Start angle
pieShape.Adjustments.Item(2) = startangle + segments(lp) ' End angle
startangle = startangle + segments(lp)
' Format the segment example
With pieShape
.Line.Weight = 1 ' Set the line thickness
.Line.ForeColor.RGB = RGB(0, 0, 0) ' black colour for the border
.Fill.ForeColor.RGB = RGB(Rnd(1) * 256, Rnd(1) * 256, Rnd(1) * 256) ' random colour for the fill
End With
Next
End Sub