Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing background color of a cell in a Word Table 1

Status
Not open for further replies.

ftpdoo

Programmer
Aug 9, 2001
202
GB
Hi,

I'm trying to change the background colour of a cell through VBA.. The cursor is positioned in the required cell and I've tried the following code:

'SELECT THE WHOLE CELL
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
'CHANGE THE BACKGROUND COLOR
Selection.Cells.Shading.BackgroundPatternColor = wdColorGray30

But the following error was returned: <Object variable or with block not set!!> :-(

THNX,
JONATHAN
 
Your code works for me. However a simpler way of doing it, if the insertion point is (anywhere) in the cell, is:

Selection.Range.Cells.Shading.BackgroundPatternColor = wdColorGray30

i.e. No need to select whole cell explicitly

M :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top