newbie46
asked on
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?
Sorry - obviously Line 6 should have your original text:
.Range.Text ="%Compliant"
ASKER
andrewssd3,
Thanks. Now, how do I set the color to none for the text? I don't see a choice of wdNone.
Thanks. Now, how do I set the color to none for the text? I don't see a choice of wdNone.
ASKER
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
Inside the With block for each cell.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
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!
ASKER
Will do. Thank you very much!!
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.