There's two ways:
Daiya has given you one, the other is styles (or AutoText).
Depending on what it is you want to colour, you either save the colour as
part of a style definition (e.g. A paragraph style or a table style) or you
save a sample of the coloured object as an AutoText.
I would use Daiya's method, personally: Turn on the Macro Recorder while
you set the colour for a border, then switch it off and edit the code it has
written to remove the extraneous lines. It will have accurately stored your
defined colour as an RGB value in the macro.
For example, here is the macro I recorded colouring a single cell in a table
a ghastly purple using the colour wheel mixer:
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 28 April 2005 by John McGhie
'
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = 12802740
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With
End Sub
Don¹t break your brain trying to work out how to derive the value 12802740
for a colour. Just record it, or use the RGB function in VBA to make it for
you. It¹s an unusual coding: basically, it¹s three eight-bit integers
multiplied and added. I think it¹s (Red + 256 + green + 512 + blue) or some
such
Recorded macros tend to record the settings from the whole dialog. To
prevent them changing things you don't want changed, you need to remove the
lines that change things you are not interested in. For general use on any
selected cell in any table, you edit the macro above as shown below:
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 28 April 2005 by John McGhie
'
With Selection.Cells.Shading
.BackgroundPatternColor = 12802740
End With
End Sub
Such quick-and-dirty recorded macros will save YOU hours. But if you want
to send them to another user, you need to add some state checking to ensure
that the user has selected a compatible object. For example:
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 28 April 2005 by John McGhie
'
If Selection.Cells.Count > 0 Then
With Selection.Cells.Shading
.BackgroundPatternColor = 12802740
End With
Else
MsgBox "You must have the selection in at least one table cell to run
this macro"
End If
End Sub
Rather that sit forever trying to learn VBA, simply run the Macro Recorder
and have a look to see what Word recorded. It usually gets it right.
Hope this helps
I have Microsoft Word: Vol X
How do I change the Color Preferences under the Paint Bucket Menu
within the "Tables and Borders Toolbar"...
so that once I set a Color to the Shade I like...
the Color retains the settings I set, everytime I apply it and...
even after I Quit Word and Open it again?
In Excel, all you have to do is go to Preferences and there is a
Section within Preferences called "Color" and once you set/MIX a color
to your Preferences it stays that way for every use of the Color after,
even after I close Excel and reopen it
Unfortunately, in Word it does not seem to be the same
Please respond and PLEASE NOTE
I know how to change the color for ONE TIME USE...
but when I try to apply the color I set at a different time Word uses
the Color that was ORIGINALLY on the Palette
--
Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.
John McGhie <
[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410