Adding Style Word 2007 problem

K

KAM

I am trying to add styles to a document through vba code. (I am only doing it
this way since .Organizercopy in vba requires the destination doc to be saved
local first...which I still don't have a work around.)

In vba, I have created "_Journal font" style to be my "base" style. All
attributes are defined explicitly in code.

Then I add another style (in vba):
Application.ActiveDocument.Styles.Add Name:="_Document", _
Type:=wdStyleTypeParagraphOnly
With ActiveDocument.Styles("_Document")
.AutomaticallyUpdate = False
.BaseStyle = "_Journal font"
.NextParagraphStyle = "_Document"
End With
With ActiveDocument.Styles("_Document").ParagraphFormat
.SpaceAfter = 10
.LineSpacingRule = wdLineSpaceSingle
.FirstLineIndent = InchesToPoints(0.25)
End With

And I have only coded for those attributes that are different from the base
style "_Journal font".

Stepping through the code, I have to add it first (which adds the new style
_Document and bases it on Normal. Then when it runs the code to base it on
"_Journal font" it SAYS it is based on "_Journal font" but it still is
retaining the formatting from Normal.

It seems like useless code to add ALL of the attributes for each and every
style that I am adding - especially since they are based on another style and
may just have one small change.

Oh please HELP!
Thanks!
 
K

KAM

This just got stranger...the newly created style is actually taking on the
attributes of the paragraph where the cursor happens to be sitting when the
code is run.

My first paragraph in the doc is Normal + 14 pt
When the new style adds, it does not take the font size from MY defined base
style, it keeps the 14 pt from where my cursor is sitting....

I don't even know how to explain this. Help.
 

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