What vba code is used in Access 2007 to back shade Word 2007 table cells?


I am using the following code to store data into a Word table from Access 2007:
with doc
'Header cells
.Tables(2).Cell(1, 1).Range.Text="Total"
.Tables(2).Cell(1, 2).Range.Text="%Compliant"
end with

do while ....
Set rw = doc.Tables(2).Rows.Add
With rw
'Text cells
.Cells(1).Range.Text = me.total
.Cells(2).Range.Text = me.Compliant
end with
loop

How can I back shade the cells of the headers cells, but not back shade the cells of the text cells?
newbie46Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andrewssd3Commented:
You want to use something like this for the hearder cells code:
With .Tables(2).Cell(1, 1)
    .Range.Text = "Total"
    .Shading.ForegroundPatternColor = wdColorGray15
End With
With .Tables(2).Cell(1, 2)
    .Range.Text = "Total"
    .Shading.ForegroundPatternColor = wdColorGray15
End With

Open in new window

Obviously this makes the background colur grey, but you should get a list through intellisense of the available colours when you type in the statements.
0
andrewssd3Commented:
Sorry - obviously Line 6 should have your original text:
    .Range.Text ="%Compliant"

Open in new window

0
newbie46Author Commented:
andrewssd3,
Thanks. Now, how do I set the color to none for the text? I don't see a choice of wdNone.
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

newbie46Author Commented:
andrewssd3,
My goal is to create the document that is attached.
Doc1.docx
0
andrewssd3Commented:
What do you mean by none?  You could try wdColorAutomatic, or wdColorWhite.  If you want the text to be invisble, set it to the same colour you gave to the background. You should be using this basic code:
    .Range.Font.Color = wdColorAutomatic

Open in new window

Inside the With block for each cell.
0
andrewssd3Commented:
OK crossed over with your comment - that's White text, and to get bold you say
With .Tables(2).Cell(1, 1)
    .Range.Text = "Total"
    .Shading.ForegroundPatternColor = wdColorGray15 ' or whatever
    .Range.Font.Color = wdColorWhite
    .Range.Font.Bold = True
End With

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newbie46Author Commented:
andrewssd3,
This works perfect! What about the additional question that I had posted within the Word doc (below):

Access VBA is appending rows to the table’s columns 1 – 9. If I create 2 tables, one containing the header info above and one containing the appended rows of data, the lines don’t match up and there is a gap between the tables. Is there a way to append the header rows to the Word doc within Access, and still be able to append the data to line up as shown in the Word doc?  

In other words, through VBA, can you control the lines being drawn and control how many cells are used for text? For example, ‘Passed’ spans 2 cells and I don’t want to see the line drawn between the 2 cells in this case.

thanks.
0
andrewssd3Commented:
Hi - as this is a different question, you should really close this one off and post a new question so that other people can take a look at it for you and so that people in the future looking for solutions will be able to find it more easily. Especially since what you're asking is not very simple!
0
newbie46Author Commented:
Will do. Thank you very much!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.