RE: Adding Style Word 2007 problem



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.

"KAM" wrote:

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!
.



Relevant Pages

  • Visual Basic for Applications Help Problem
    ... Under Office 2003 Professional Edition with SP1, if I open the VBA ... Basic for Applications.) ... sits there with the mouse cursor changed to a hand. ... Assistance pane on the right of the window that gives me the chance to ...
    (microsoft.public.office.misc)
  • Re: An odd problem
    ... Please reply to the newsgroup unless you wish to avail yourself of my ... It only happens with Word VBA ... In fact after quickly experimenting I noticed that the cursor ... > supposed to everywhere else even in Word or vba code and their ...
    (microsoft.public.word.vba.beginners)
  • Re: Cant double click to select a word, in a Microsoft Word document
    ... the paragraph :-) Notice how the pointer continues to appear as an I-beam. ... In Page Layout view (with an insertion point selection so the I-beam ... pointer shows when hovering over text), move the cursor to the grey area ... Start with the cursor in the left grey area, ...
    (microsoft.public.mac.office.word)
  • Re: Upper Case
    ... It turns out to be surprisingly hard to do this with VBA. ... to exit from a table cell. ... or used the mouse to move the cursor. ... typed there, whether upper or lower case, would appear in upper case. ...
    (microsoft.public.word.docmanagement)
  • An odd problem
    ... I know this is more of a technical issue rather than the sort of ... It only happens with Word VBA ... In fact after quickly experimenting I noticed that the cursor ... supposed to everywhere else even in Word or vba code and their ...
    (microsoft.public.word.vba.beginners)

Loading