LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Trying to loop through all shapes on multiple worksheets and change color

Hi - I have a workbook with multiple sheets - each having a few shapes
on it. I want to change the color of the fill and line for each one.
My code works ok if I run it on just one sheet, but if I try and run it
on one sheet right after the other (with a subroutine calling this sub
twice), it gives me the "Object doesn't support the property or method"
error. Sometimes this even happens if I run the macro twice in a row
manually, sometimes it doesn't. I am seriously at my wits end....can
someone please help?

Thanks!

Here is the code I am bombing out
on...."Selection.ShapeRange.Fill.ForeColor.SchemeC olor = 16" (or
whichever case it is on)


For Each sh In myDocument.Shapes
sh.Select
If sh.Type = 2 Then
Select Case colorscheme

Case "OcOl"
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 16
Selection.ShapeRange.Line.ForeColor.SchemeColor = 16
With Selection.Characters.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = fontcolor
End With

Case "BoTe"
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 34
Selection.ShapeRange.Line.ForeColor.SchemeColor = 34
With Selection.Characters.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = fontcolor
End With
Case "EaTe"
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 34
Selection.ShapeRange.Line.ForeColor.SchemeColor = 34
With Selection.Characters.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = fontcolor
End With
Case "BoEa"
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 35
Selection.ShapeRange.Line.ForeColor.SchemeColor = 35
With Selection.Characters.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = fontcolor
End With
Case Else
'Olive-Ocean is default
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 1
Selection.ShapeRange.Line.ForeColor.SchemeColor = 1
With Selection.Characters.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = fontcolor
End With

End Select


End If
Next

 
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
Change multiple worksheets at one time to print in color Sundance Excel Discussion (Misc queries) 1 January 5th 10 10:34 PM
How do i change the size of multiple shapes at the same time? Amber Excel Discussion (Misc queries) 0 September 25th 08 09:14 PM
Loop to change cell color based on found value? gaba Excel Programming 3 November 3rd 04 02:33 PM
Summing loop for multiple worksheets Brian Easton Excel Programming 1 September 25th 04 12:43 AM
PROB: Grouping Shapes With An Array Loop Boicie Excel Programming 2 January 14th 04 08:21 PM


All times are GMT +1. The time now is 10:46 PM.

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

About Us

"It's about Microsoft Excel"