How to I set the default Font values using code.

C

Cresta

Hello all
I currently have the following code which set the font properties for the
current document.

With applicationObject.ActiveDocument.Styles("Normal").Font
.Name = "Tahoma"
.Size = 20
.Bold = 0
.Italic = 0
.Underline = 0
End With

But when I close the active document and open a new one the settings have
reverted to the original Word values.

How to I set the default Font values using code.

Thanks
 
S

Stefan Blom

The code you have been using sets the defaults of the Normal style for the
current document. To copy the style to the attached template, you would
have to also make use of the OrganizerCopy method. For example:

Application.OrganizerCopy Source:=ActiveDocument.FullName, _
Destination:=ActiveDocument.AttachedTemplate.FullName, _
Name:="Normal", Object:=wdOrganizerObjectStyles

(Note that I have made use of the global Application and ActiveDocument
properties in Word VBA. They won't work if you are automating Word from a
different application, as you probably already know.)
 
C

Cresta

Thanks Stefan, worked a treat

Stefan Blom said:
The code you have been using sets the defaults of the Normal style for the
current document. To copy the style to the attached template, you would
have to also make use of the OrganizerCopy method. For example:

Application.OrganizerCopy Source:=ActiveDocument.FullName, _
Destination:=ActiveDocument.AttachedTemplate.FullName, _
Name:="Normal", Object:=wdOrganizerObjectStyles

(Note that I have made use of the global Application and ActiveDocument
properties in Word VBA. They won't work if you are automating Word from a
different application, as you probably already know.)
 

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