By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

Issue: MS Access Exporting Data to Word and Coloring Text

Brilstern
100+
P: 208
I am using VBA to export a string value in MS Access to a table in MS Word. After exporting I would like to have that text change colors. I have been able to successfully do this but I am having problems with using the colors that I need. Using Words Font.ColorIndex class object I am able to use "wdRed" or "wdYellow." I cannot use any form of Orange and I cannot find any answers. I have tried using RGB and Access colors but they will not pass to the Word object class. Below is the method I am using.

Expand|Select|Wrap|Line Numbers
  1. doc.Tables(3).Cell(2, 3).Range.Font.ColorIndex = wdRed
Anyone know how to call more colors or how to do this with a different method? The ColorIndex is limited to the following as far as I can tell.

Expand|Select|Wrap|Line Numbers
  1. Number   Text Color     Word Constant
  2. 0       Auto            wdAuto
  3. 1       Black           wdBlack
  4. 2       Blue            wdBlue
  5. 3       Cyan            wdTurquoise
  6. 4       Green           wdBrightGreen
  7. 5       Magenta         wdPink
  8. 6       Red             wdRed
  9. 7       Yellow          wdYellow
  10. 8       White           wdWhite
  11. 9       Dark Blue       wdDarkBlue
  12. 10      Dark Cyan       wdTeal
  13. 11      Dark Green      wdGreen
  14. 12      Dark Magenta    wdViolet
  15. 13      Dark Red        wdDarkRed
  16. 14      Dark Yellow     wdDarkYellow
  17. 15      Dark Gray       wdGray50
  18. 16      Light Gray      wdGray25
Mar 9 '15 #1
Share this Question
Share on Google+
8 Replies


Brilstern
100+
P: 208
GOT IT!

I changed classes to Font.Color. It has more available colors.

Expand|Select|Wrap|Line Numbers
  1. doc.Tables(3).Cell(2, 3).Range.Font.Color = wdColorOrange
Mar 9 '15 #2

twinnyfo
Expert Mod 2.5K+
P: 3,482
Stevan,

I have not tried it, but does the Font.Color Property allow usage of the RGB(x,x,x) function? That would enable all 16 million colors.
Mar 9 '15 #3

Brilstern
100+
P: 208
It does indeed. Looks like it is just a bad choice in the objects using Font.ColorIndex vs Font.Color. Noted for next time!
Mar 9 '15 #4

NeoPa
Expert Mod 15k+
P: 31,768
Excel Ranges have a parallel pair of properties where ColorIndex and Color are both available. Color gives a lot more flexibility but ColorIndex is great if you're working at a very basic level.

TwinnyFo's already mentioned the RGB() function ;-)
Mar 10 '15 #5

Brilstern
100+
P: 208
Hey NeoPa :)

Yeah, I looked into the Excel Ranges but I wasn't sure if I could call an Excel Property to Word from Access... If that makes any sense.

Also, how did you format the properties like that?!? Kinda cool :)
Mar 10 '15 #6

NeoPa
Expert Mod 15k+
P: 31,768
Hi Stevan.

It's the [ICODE][/ICODE] BB code tag.
Mar 10 '15 #7

twinnyfo
Expert Mod 2.5K+
P: 3,482
Way off topic.... I know! Is there a list of available BB Code tags that posters can see, so we all know how to do your fancy little tricks?
Mar 10 '15 #8

Brilstern
100+
P: 208
Thanks man! Appreciate it!

TF
Actually found that yesterday after Adrian pointed out the other BB code. BBCODE It is under the FAQ How to format your Articles and Posts.
Mar 10 '15 #9

Post your reply

Sign in to post your reply or Sign up for a free account.