![]() |
|
|
|
#1
|
||||
|
||||
|
For a single selected shape you could change:
With ActiveDocument.Shapes(1) to: With Selection.ShapeRange(1) You could, of course, change the index # to refer to the 2nd, 3rd, etc. Shape in the document or selection, as appropriate. For multiple shapes, you'd need to implement a loop. To work with text in a shape, refer to its .TextFrame.TextRange property.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Ah, brill, thanks. I am mostly okay with figuring out properties, but the ShapeRange thing is new. Thanks so much for your speedy reply.
|
|
#3
|
|||
|
|||
|
Thank you very much for your help -- for the benefit of others and for posterity, here's what I am using. I have two sub routines. (Added a 3rd which includes a loop so it does all the selected shapes.)
1 - Changes a selected shape with a number in it to a cute little red circle .18" h/w, and applies a style (Stepcircles) to the number inside the circle. Code:
Sub redCircle()
With Selection.ShapeRange(1)
.AutoShapeType = msoShapeOval
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.BackColor.RGB = RGB(255, 255, 255)
.Line.Weight = 1
.Line.ForeColor.RGB = RGB(255, 0, 0)
.Height = InchesToPoints(0.18)
.Width = InchesToPoints(0.18)
.TextFrame.TextRange.Style = "Stepcircles"
.TextFrame.MarginBottom = 0
.TextFrame.MarginRight = 0
.TextFrame.MarginTop = 0
.TextFrame.MarginLeft = 0
End With
End Sub
Code:
Sub redOutlineOneRectangle()
With Selection.ShapeRange(1)
.AutoShapeType = msoShapeRectangle
.Line.Weight = 1
.Line.ForeColor.RGB = RGB(255, 0, 0)
End With
End Sub
Code:
Sub redCircles()
Dim allShapes As ShapeRange
Dim myShape As Shape
Set allShapes = Selection.ShapeRange
For Each myShape In allShapes
With myShape
.AutoShapeType = msoShapeOval
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Fill.BackColor.RGB = RGB(255, 255, 255)
.Line.Weight = 1
.Line.ForeColor.RGB = RGB(255, 0, 0)
.Height = InchesToPoints(0.18)
.Width = InchesToPoints(0.18)
.TextFrame.TextRange.Style = "Stepcircles"
.TextFrame.MarginBottom = 0
.TextFrame.MarginRight = 0
.TextFrame.MarginTop = 0
.TextFrame.MarginLeft = 0
End With
Next myShape
End Sub
Last edited by Karin Carlson; 08-09-2017 at 10:07 PM. Reason: added another code example with loop |
|
| Tags |
| shape, shapes |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to change all text color to black in all docx files in a selected folder
|
joewoods | Word VBA | 13 | 05-16-2016 06:29 PM |
Margin change for selected text in Word 7
|
Richtriebe | Word | 4 | 03-14-2016 11:57 AM |
Change ComboBox Properties
|
ll4u76 | Word VBA | 1 | 03-31-2012 05:08 AM |
| Change object properties by clicking | PopOnTheAir | PowerPoint | 7 | 03-16-2012 02:13 PM |
| Change cell color everytime a value is selected in dropdown list | angelica_gloria | Excel | 4 | 01-27-2012 06:47 PM |