changing style names

J

JulieD

anyway of changing style names using code?

i have 300 files which all need to be inserted into one document without
changing formatting and the only way i can think of doing it is to change
the used styles in each of the source documents to a unique name (by
appending the file name) so that when i bring them into the target document
they retain their formatting and don't take on the characteristics of the
style in the document.

Cheers
JulieD
 
J

Jezebel

The NameLocal property is the way to rename a style. If the style is
built-in, you get a name like "Normal, MyName". If not built-in it is simply
renamed --

ActiveDocument.Styles("Normal").NameLocal = "MyName"

All paragraphs using the style are automatically updated for the new name.
But since you can have only one instance of each built-in style (whatever
you call it), you'll have to convert the built-ins to custom styles first,
otherwise you'll still have a conflict when you merge your documents --

For each style in the document --

If it's actually used in the document --

NewName = Style.Name & "_" & Document.Name

If Style.Built-in then ...
Create a new style called NewName
Copy the attributes of the existing style
Replace all references to the existing style with new new style

Else
Rename the style to NewName
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < JulieD > écrivait :
In this message, < JulieD > wrote:

|| anyway of changing style names using code?
||
|| i have 300 files which all need to be inserted into one document without
|| changing formatting and the only way i can think of doing it is to change
|| the used styles in each of the source documents to a unique name (by
|| appending the file name) so that when i bring them into the target
document
|| they retain their formatting and don't take on the characteristics of the
|| style in the document.
||

And to add to Jezebel's comments, I think there is a limit at how many
styles a document can have.
A document easily uses 5 to 7 styles. Let's be conservative and say 4. If
you merge 300 documents, you will end up with 1 200 styles.
Can Word handle that without crashing?
I hope someone can tell you if I'm way off or not here...
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

JulieD

Hi guys

thanks for the responses ... i was dealing with this via a 3rd party and
didn't get to have a look at the 300 docs until today and found out that the
formatting is actually consistent among them (well the ones i looked at
anyway) it just wasn't consistent with the new document they were being
inserted into. So all i did was to change the code to insert the 299 into
the 1st one and everything looks fine - couple of extra paragraph marks need
to be put in, but they can do that :)

Cheers
JulieD
 
J

Jezebel

According to the Limits list for W2000, you can have 10,000 styles in a
document or template. I've never come remotely close, so I've no idea
whether Word can actually manage that. You certainly wouldn't want to be
displaying the style drop-down too often.

Maximum length of a style name is 255 characters.
 
C

Charles Kenyon

Not for the styles built into Word. If you have the WOPR utility it has a
function to copy style formatting to a new style. You could then use replace
to change the formatting to the new style.

Generally, you want text that serves the same purpose in a document to have
the same formatting. Are you sure that you want to be maintaining the
differences?

Also, I would be surprised if all the formatting in these documents was done
using styles. If it was, you have a very disciplined group of users. My
guess would be that the bulk of it was done using direct formatting.
 
J

JulieD

Hi Charles

thanks for the input - my testing proved that what i wanted to do i couldn't
do with built-in styles .. what is a WOPR utility??

and, yes, i was seriously amazed that they had used styles at all (but as i
said in my last post - the styles were consistent across the documents so in
the end it was an easy solution).

Thanks again
Cheers
JulieD
 
C

Charles Kenyon

WOPR is a major commercial Add-In for Office (primarily Word) by Woody
Leonhard.
See http://wopr.com

It is included in the appropriate version of Using Microsoft Office Special
Edition from Que publishing.
 
J

JulieD

Hi Charles

i knew i should load up disks that come with the manuals i buy :)

i'll go check it out.

Thanks
JulieD
 

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