Macro to change font

M

Mickey

Does any know if there is a macro that will change the font in all the tables
in a document?

Thanks,
Mickey
 
E

Edward Thrashcort

record a macro that changes the font if you don't know the code
to make the change you require, then create a macro that wraps
the recorded code in a for-loop

Sub tablefontchange()
Dim aTable As Table
For Each aTable In ActiveDocument.Tables
aTable.Select
Selection.Font.Name = "Times New Roman"
Next
End Sub


Eddie
 
G

Greg Maxey

Eddie,

You might want to consider using "range" for this sort of thing.
There is no need to actually select the individual tables.

Sub tablefontchange()
Dim aTable As Table
For Each aTable In ActiveDocument.Tables
aTable.Range.Font.Name = "Times New Romanl"
Next
End Sub
 
E

Edward Thrashcort

Yep I know.

I couldn't be bothered to load word to get the syntax right so I wrote it
from memory the easy way.

The Selection object, although functional, can be fraught with gotchas

Eddie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top