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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change font bold of a cell in a table in word from VB 1

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
I've used some code from johnwm in thread222-589129 some time ago to help me make the table. From that I've figured out how to change the "header row" background color. Now I'm trying to change the "header row" font to bold but I'm having diffieculty. Can someone help. Here is the how I change the color of row 1 for each column.

Code:
'This will change the color of the header row in the table
    With MyRange.Tables.ITEM(1)
    
        For g = 1 To .Columns.Count
[blue]'            .Cell(1, g).Select.Font.Bold = wdToggle[/blue]
            .Cell(1, g).Shading.BackgroundPatternColor = wdColorYellow
        Next g
    
    End With

The remmed out line is the last thing I've tried. I also tried to reocord a macro but that didn't help much. Recording a macro in word doesn't seem to work like recording one in Excel. Thanks for the help!!
 
You can still use the Record Macro technique - but you seem to need keystrokes rather than mouse to do your moving etc. Try this
Code:
With ThisDocument.Tables.Item(1)
For g = 1 To .Columns.Count
.Cell(1, g).Select
'Selection.Font.Name = "Arial"
Selection.Font.Bold = True
Next
End With
I've remmed out the font change, but left it there to show how it works

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Thanks for the tip Johnwm. I worked over the weekend and figured out how. What you've show works also. Here is the way I ended up getting it done.

Code:
Dim objTable        As Word.Table
.
.
.

'make first row bold
Set objTable = objWord.ActiveDocument.Tables(1)
objTable.Rows(1).Range.Font.Bold = True

I may go back and use your tip as I don't need the table object.


I tried to have patience but it took to long! :) -DW
 
You're welcome - and thanks!

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top