Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Shading selected selection to 5% programatically?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
StargateFanFromWork - 01 Nov 2005 23:23 GMT
I recorded a test macro just now to shade selected cells to 5%.  It's a
macro I'll need enough to keep but the recorded keystrokes include a lot of
garbage I don't need.  There may be tables that have different attributes,
etc., than what I recorded the macro with that will get changed.  Here's the
recording:

**********************
Sub Macro1()
'
   With Selection.Cells
       With .Shading
           .Texture = wdTextureNone
           .ForegroundPatternColor = wdColorAutomatic
           .BackgroundPatternColor = wdColorGray05
       End With
       With .Borders(wdBorderLeft)
           .LineStyle = wdLineStyleSingle
           .LineWidth = wdLineWidth050pt
           .Color = wdColorAutomatic
       End With
       With .Borders(wdBorderRight)
           .LineStyle = wdLineStyleSingle
           .LineWidth = wdLineWidth050pt
           .Color = wdColorAutomatic
       End With
       With .Borders(wdBorderTop)
           .LineStyle = wdLineStyleSingle
           .LineWidth = wdLineWidth050pt
           .Color = wdColorAutomatic
       End With
       With .Borders(wdBorderBottom)
           .LineStyle = wdLineStyleSingle
           .LineWidth = wdLineWidth050pt
           .Color = wdColorAutomatic
       End With
       With .Borders(wdBorderHorizontal)
           .LineStyle = wdLineStyleSingle
           .LineWidth = wdLineWidth050pt
           .Color = wdColorAutomatic
       End With
       With .Borders(wdBorderVertical)
           .LineStyle = wdLineStyleSingle
           .LineWidth = wdLineWidth050pt
           .Color = wdColorAutomatic
       End With
       .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
       .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
       .Borders.Shadow = False
   End With
   With Options
       .DefaultBorderLineStyle = wdLineStyleSingle
       .DefaultBorderLineWidth = wdLineWidth050pt
       .DefaultBorderColor = wdColorAutomatic
   End With
End Sub
**********************

I'm guessing here but it seems that the line near the beginning of the code
that is this:

           .BackgroundPatternColor = wdColorGray05

is what actually did the shading?  Is there a way to have a macro to just
shade rather than all the rest?  Pls advise and thanks.  :oD
Tony Jollans - 02 Nov 2005 00:49 GMT
Your guess is good and, yes, just remove the bits you don't want:

Sub Macro1()
'
   With Selection.Cells
       With .Shading
           .Texture = wdTextureNone
           .ForegroundPatternColor = wdColorAutomatic
           .BackgroundPatternColor = wdColorGray05
       End With
   End With
End Sub

--
Enjoy,
Tony

> I recorded a test macro just now to shade selected cells to 5%.  It's a
> macro I'll need enough to keep but the recorded keystrokes include a lot of
[quoted text clipped - 60 lines]
> is what actually did the shading?  Is there a way to have a macro to just
> shade rather than all the rest?  Pls advise and thanks.  :oD
StargateFan - 02 Nov 2005 03:55 GMT
>Your guess is good and, yes, just remove the bits you don't want:

Super.  :oD

>Sub Macro1()
>'
[quoted text clipped - 6 lines]
>    End With
>End Sub

Thank you.  I've just emailed myself at the office with that snippet
of code so I have it first thing tomorrow.

Thanks.  :oD

>--
>Enjoy,
[quoted text clipped - 67 lines]
>> is what actually did the shading?  Is there a way to have a macro to just
>> shade rather than all the rest?  Pls advise and thanks.  :oD
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.