copying colour from a table cell to another table cell

P

Purplejopeg

I have produced a specific colour in a cell, I now want to use it in another
table in the same document, how can I copy the colour?
 
H

Helmut Weber

Hi Purplejopeg,

I couldn't find a way other than to record the source color,
select the target cells afterwards,
and apply the recorded color.

Of course, some vba-knowledge is essential.

Option Explicit
Dim lngColor As Long ' global for module
' -------------------------------
Sub GetColor()
lngColor = Selection.Cells(1).Shading.BackgroundPatternColor
End Sub
' -------------------------------
Sub SetColor()
Selection.Cells.Shading.BackgroundPatternColor = lngColor
End Sub

You may assign the macros to convenient shortcuts.

The value of lngColor might not stay defined forever,
depending on what you do between getcolor and setcolor.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
P

Purplejopeg

Thanks, but I don't have any vba knowledge, guess it is visual basic. I have
managed to find out the colour breakdown so all is not lost, but it is very
slow.
 
K

Klaus Linke

If you've applied the colour once, you can apply it to other cells with F4
(EditRedoOrRepeat).
I thought it would be enough to open and close the BordersAndShading dialog
with the cursor in the cell you want to "copy" from, to pick up the colour,
but that does not seem to work in Word 2003.

Regards,
Klaus
 
S

Stefan Blom

FWIW, it doesn't seem to be working in Word 2007 either. The *borders* can be
picked up by visiting the Borders and Shading dialog, and then pressing F4,
though.
 

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