Results 1 to 6 of 6
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Bug in recording 'add new character style'? (Word97/SR2)

    The macro TESTaddStyle is a testbed for the function addStyle,

    addStyle is supposed to facilitate the addition of a set of character styles to the current document, loading them as well into the attached template.

    addStyle is a stripped-down version of a recorded macro. I want only the emphasis charcteristics (bold, italic, underline) and the colour (green) to be affected.

    Some notes:

    1) From Word97, if I execute the command Format, Styles, New, AddTotemplate and the active document is itself a template, Word copes with it quite well; when I run the function addStyle on a template, Word97 barfs on the Application.OrganizerCopy with "Run-time error '4198' Command Failed". Hmm. I guess they use On Error within Word itself.

    2) Despite cutting the ".size = 11" out of the recorded macro, running the function forces size=11 on the new font? How does Word97 do that?.

    3) When recording the macro steps of creating a new character style, the size box is the only box to be loaded (to the value 11).

    4) Unless I'm being a tad more stupid than usual at this hour of the morning, it seems that my macro always add italic font to the combination. My use of the boolean switches seems Ok to me (but see "stupid/blind" above).

    5) Regarding points (2) and (5) above I've a suspicion that amounts to sneaking that deep within the bowels of Word97, the latest values for .size and .italic are being preserved from one call to the next, and are being dragged up by susequent calls.

    6) I should test this out next time I get a head of steam under my other drive with Office XP, I know ....


    <pre>Sub TESTaddStyle()
    Call addStyle("csB", True, False, False)
    Call addStyle("csI", False, True, False)
    Call addStyle("csU", False, False, True)
    Call addStyle("csBI", True, True, False)
    Call addStyle("csBU", True, False, True)
    Call addStyle("csIU", False, True, True)
    Call addStyle("csBIU", True, True, True)
    End Sub
    '
    '
    Public Function addStyle(strStyleName, blnBold, blnItalic, blnUnderline)
    ActiveDocument.Styles.Add Name:=strStyleName, Type:=wdStyleTypeCharacter
    ActiveDocument.Styles(strStyleName).BaseStyle = "Default Paragraph Font"
    With ActiveDocument.Styles(strStyleName).Font
    .bold = blnBold
    .italic = blnItalic
    If blnUnderline Then
    .underline = wdUnderlineSingle
    Else
    End If
    .ColorIndex = wdGreen
    End With
    ' Application.OrganizerCopy Source:=ActiveDocument.FullName, Destination:= _
    ActiveDocument.AttachedTemplate.FullName, Name:=strStyleName, Object:= _
    wdOrganizerObjectStyles
    End Function

    </pre>


  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Bug in recording 'add new character style'? (Word97/SR2)

    I would think that the "size" attribute, since you are not setting it, is the size attribute of the default paragraph font for the text to which you are applying the character style. However, I use character styles so rarely that this is but a guess.

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Bug in recording 'add new character style'? (Word97/SR2)

    I guess 1) isn't surprising. You try to copy a style from a template to the same template.

    2) My guess regarding size is the same as Jefferson's. Do you really see "11 pt" as part of the style definition? In Word2000, I don't see that.

    3) Again, in Word2000, the font size box is empty.

    4) In Word2000, the character style gets "italic" or "not italic", as you have defined them in the macro. But here, things get really crazy. I've been convinced that the implementation of character styles stinks, and this is another proof.
    I was about to suggest that you don't set bold (or italic or underline) to false, so that the setting of the underlying paragraph style ripples through. But it turns out that the setting in the character style is ignored in any case. If I apply your style csI (which has the setting "not bold") to some heading which is bold, the text stays bold!

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Bug in recording 'add new character style'? (Word97/SR2)

    > the size attribute of the default paragraph font for t

    I have just re-tried my experiment. Created a new template, created a new character style, and this time the font size box was NOT pre-loaded with 11pt. Odd.

    FWIW 11pt is not my default size, either.

    I'll have to dig a little deeper. It wasn't earth-shaterring, just strange.

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Bug in recording 'add new character style'? (Word97/SR2)

    Hi Chris,

    Do you think it's sensible that if you apply a character style defined as "not bold" to a bold paragraph, it stays bold? Looks like a bug to me <img src=/S/puke.gif border=0 alt=puke width=60 height=15>

    Klaus

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Bug in recording 'add new character style'? (Word97/SR2)

    > it stays bold?

    Thanks for the nudge. I'm leaving your email notification in my In Box until I can be a tad more exhaustive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •