Change doct's font + font size _without_ selecting?

S

StargateFan

I always feel that this type of code isn't the most efficient where a
change has to be done through a selection. Here is part of a recorded
macro where the font gets changed to Courier New, 10pt:

Selection.WholeStory
With Selection.Font
.Name = "Courier New"
.Size = 10
End With
Selection.HomeKey Unit:=wdStory

Is there a way to do it cleanly through a "change document's font"
type of code, without a selection? This time I was more patient and
searched and searched first before posting here <g>. But the archives
and the vbe help haven't yielded anything I can use. I'm probably
asking for something not precise enough, again. Anyway, TIA.
 
D

Doug Robbins - Word MVP

Don't use the Selection object.

With ActiveDocument.Range.Font
.Name = "Times New Roman"
.Size = 10
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

StargateFan

Don't use the Selection object.

With ActiveDocument.Range.Font
.Name = "Times New Roman"
.Size = 10 8>End With

Thanks, this sure did help. The problem with recording keystrokes is
that you don't know how to change them. I knew from seeing other
macros that I'd need to replace selection parts with "With
ActiveDocument." so it's good to see this new example.
 
K

Klaus Linke

Hi,

If you used styles to format your doc, change the style's font:

With myStyle.Font
'...

If all the document is in the same style:

With Selection.Style.Font
' ...

Regards,
Klaus
 
S

StargateFan

Hi,

If you used styles to format your doc, change the style's font:

With myStyle.Font
'...

If all the document is in the same style:

With Selection.Style.Font
' ...

More stuff for my Tips folder! Thanks. :eek:D
 

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