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 / March 2005

Tip: Looking for answers? Try searching our database.

Cell shading always black

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Boyce - 19 Mar 2005 17:08 GMT
ActiveDocument.Tables(1).Cell(cellStart, 2).Shading.BackgroundPatternColor =
wdBlue

Always results in black cell shading, regardless of the color specified.
Anyone have thoughts as to why? Using BackgroundPatternColorIndex always
results in no shading.

Thanks,

Jim
Helmut Weber - 20 Mar 2005 11:58 GMT
Hi Jim,

take a close look at the object catalog.

wdblue (value = 2) is an element of the class wdcolorindex.

So when using

With ActiveDocument.Tables(1).Cell(1, 2).Shading
  .BackgroundPatternColor = wdBlue
End With

you get a color that isn't absolutely black, but almost black,
exactly it is RGB(2, 0, 0).

Try, e.g.
.BackgroundPatternColor = wdColorBlue

However, I don't understand what could be wrong with:

With ActiveDocument.Tables(1).Cell(1, 2).Shading
  .BackgroundPatternColorIndex = wdBlue
End With

Works perfectly, here and now.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Jim Boyce - 31 Mar 2005 00:01 GMT
Helmut, thanks for the reply. No matter what value I use, the cell is always
black. Here is the code:

Word.ActiveDocument.Tables(tblIndex).Cell(cellStart,
2).Shading.BackgroundPatternColor = wdColorBlue

I've tried the grays, colors, etc., all with the same effect.

Jim

> Hi Jim,
>
[quoted text clipped - 28 lines]
> Word XP, Win 98
> http://word.mvps.org/ 
Helmut Weber - 31 Mar 2005 18:35 GMT
Hi Jim,
one more example. Put the cursor in a cell in a Word document,
and step through the following in single step mode in Word-(!)-VBA.

Sub test09887()
Selection.Collapse
Selection.Cells(1).Shading.BackgroundPatternColor = wdColorBlue
ActiveDocument.Undo 1
Selection.Collapse
Selection.Cells(1).Shading.BackgroundPatternColorIndex = wdBlue
ActiveDocument.Undo 1
Selection.Collapse

Though, if you are approaching Word form another application,
and don't use early binding and don't use option explicit
or something similar in the calling application, then whatever
color (or unknown variable you choose), Word will always treat
it as 0 (zero), which is black.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Jim Boyce - 31 Mar 2005 23:26 GMT
That was it. I was automating Word from Outlook. When I enter a value rather
than use a constant, it works as expected. Thanks for the help!

Jim

> Hi Jim,
> one more example. Put the cursor in a cell in a Word document,
[quoted text clipped - 21 lines]
> Word XP, Win 98
> http://word.mvps.org/
Cindy M  -WordMVP- - 31 Mar 2005 18:57 GMT
Hi Jim,

> No matter what value I use, the cell is always
> black. Here is the code:
[quoted text clipped - 3 lines]
>  
> I've tried the grays, colors, etc., all with the same effect.

Version of Word? Does your printer support color printing? Or
is it set to print only black-and-white? Are you able to color
shade cells in tables when NOT using VBA?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8
2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)
 
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.