Word Shapes and Drawing Canvas

J

Jon Borel

Hello,

In Word 2003, I am trying to change the color of all Word Shapes (lines and
boxes) from black to orange (RGB(224,107,60)). I can change the color of the
shapes (lines and boxes) that are NOT in a Drawing Canvas using the following
code:

Sub UpdateCalloutLines()
ActiveDocument.Content.ShapeRange.Line.ForeColor = RGB(224, 107, 60)
End Sub

What I can't figure out is how to update these same types of shapes (lines
and boxes) when they occur in drawing canvasses.

Any suggestions?

Thanks,
Jon
 
J

Jon Borel

Update,

I've figured out out to update the line color of all of the shapes (lines
and boxes) that are in a canvas, but each canvas has to be selected manually:

Selection.ShapeRange.CanvasItems.SelectAll
If Selection.HasChildShapeRange = True Then
With Selection.ChildShapeRange.Line
.ForeColor = RGB(224, 107, 60)
.Weight = 1.5
End With
Else
MsgBox "This canvas contains no callouts to format."
End If

QUESTION: Is there a way to select all canvas objects at once, or for Word
to move from one to the next automatically? I'm looking for something along
the lines of:

Do while more canvas items exist
'Change the line colors using the code above
Goto next canvas
Loop
 
D

Doug Robbins - Word MVP

Try:

Dim i As Long
With ActiveDocument
For i = 1 To .Shapes.Count
.Shapes(i).CanvasItems.SelectAll
If Selection.HasChildShapeRange = True Then
With Selection.ChildShapeRange.Line
.ForeColor = RGB(224, 107, 60)
.Weight = 1.5
End With
Else
MsgBox "This canvas contains no callouts to format."
End If
Next i
End With

You may want to get rid of the Else

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Jon Borel

Hi Doug,

Thanks a million!

I get a run-time error "This member can only be accessed for a group" with
the line
".Shapes(i).CanvasItems.SelectAll" indicated in yellow.

If you would explain what this error means, I would appreciate it; however,
I used "On Error Resume Next" as a workaround and your code works (otherwise)
perfectly!

Thanks again,
Jon
 
D

Doug Robbins - Word MVP

Maybe the following will avoid the error:

Dim i As Long
Dim srange As ShapeRange
With ActiveDocument
For i = 1 To .Shapes.Count
Set srange = .Shapes(i).CanvasItems.Range
srange.CanvasItems.SelectAll
If Selection.HasChildShapeRange = True Then
With Selection.ChildShapeRange.Line
.ForeColor = RGB(224, 107, 60)
.Weight = 1.5
End With
Else
MsgBox "This canvas contains no callouts to format."
End If
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Jon Borel

Compile Error: "Argument not Optional" on the line:

Set srange = .Shapes(i).CanvasItems.Range

(with ".Range" highlighted in debug)
 
D

Doug Robbins - Word MVP

Sorry, I do not know why the original error occurrs and if the following
does not work, maybe you have to go back to using the On Error Resume Next

Dim i As Long
Dim srange As ShapeRange
With ActiveDocument
For i = 1 To .Shapes.Count
With .Shapes(i)
If .Child = msoTrue Then
With .Line
.ForeColor = RGB(224, 107, 60)
.Weight = 1.5
End With
Else
MsgBox "This canvas contains no callouts to format."
End If
End With
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Jon Borel

Doug,

Thanks so much for your time. As you assumed, I had the best luck with your
first solution, prefaced with On Error Resume Next.

Thank you again!
Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top