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

Changing styles in word

Status
Not open for further replies.

NNNNN

MIS
Dec 2, 2002
90
0
0
GB
The following macro will change the font name and size for all styles (not so sure about ALL)

>>
For x = 1 To ActiveDocument.Styles.Count
With ActiveDocument.Styles
If .Item(x).InUse = True Then
With ActiveDocument.Styles(.Item(x).NameLocal).Font
.Size = 12
.Name = "Times New Roman"
End With
End If
End With
Next
<<

HOWEVER

I have documents where the style id ‘Normal + 10pt’ which I need to change

Whilst the code happily changes the Normal to Times New Roman and the size to 12
It does nothing with the ‘Normal +10pt’

Haw can I fix this please
 
So many possibilities! As you want to change the whole document you could try:

Code:
[blue]ActiveDocument.Content.Font.Reset[/blue]

but that might change too much - if so it gets more involved.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 




NNNNN,

I notice that over the past 6 years, you have posted 49 threads and have received many good tips related to your stated needs. Yet, you have responded only ONCE, to
[blue]
Thank Tek-Tip Contributor
for this valuable post!
[/blue].

The little purple Stars accomplish several important things.

First, it gives positive feedback to contributors, that their posts have been helpful.

Second, it identifies threads as containing helpful posts, so that other members can benefit.

And third, it identifies the original poster (that's YOU, BTW), as a grateful member, that not only receives, but is willing to give tokens of thanks.



Also, when you post code, [red]>> <<[/red] does little to help your cause. Please check out TGML Tags (search in this page for TGML: Read, Understand, Use)

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
As Tony mentions, so many possibilities. Using his Reset may work for you, but if it does not then you may have to try something, as he puts it, more involved.

If you have things like 'Normal + 10pt', that that is BAD.

1. a good Word document never uses Normal, at all.

2. a good Word document never uses a manually modified Normal (as 'Normal + 10pt' is).

3. a good Word document uses explicit, and only explicit, Styles. That is how Word is designed to be used.

"It does nothing with the 'Normal +10pt' "

No, it won't. Why? Because you are actioning (correctly) Styles with:
Code:
With ActiveDocument.Styles
and Normal + 10pt is NOT a real Style. It is not part of ActiveDocument.Styles.

Say you can see Normal + 10pt in the Style dropdown. If you try to change something TO that "style" by code, it will fail.
Code:
Selection.Style = "Normal + 10pt"

Run-time error '5834'

Item with specified name does not exist.


Because it does NOT exist in the Styles collection.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top