Results 1 to 7 of 7
  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

    Font with lreading whitespace (Word 2000)

    A couple of days ago there lodged in my head, from reading somewhere, that white space preceding a selection/range does not contribute towards the determination of local BOLD formatting (and presumably Italic, Underline, Color etc). I can't locate the reference, but nonetheless decided to go ahead.
    Imagine my surprise to discover that Word2000/VBA does it for me!
    In the image below I have selected the non-bold space character preceding the word "selected" and asked <pre>?selection.Font.Bold</pre>

    The result is -1 or TRUE. VBA ignores the leading whitespace, which is not bolded, and returns the status of the first non-white space character, "s", which IS bold.
    When I select "old sele" and ask <pre>?selection.Font.Bold</pre>

    the result is 9999999 otherwise known as "mixed", which I expect.

    (later) I should add that using <pre> Dim blnResult As Boolean
    blnResult = rng.Font.Bold ' simple test, no stripping white space characters</pre>

    only clouds the issue, since a result of Mixed=99999 will cause me to see blnResult=True, whereas I should really be ascertaining the font.Bold of the leading non-white space character.
    Attached Images Attached Images
    • File Type: jpg 1.JPG (3.0 KB, 0 views)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Font with lreading whitespace (Word 2000)

    If you look at the Formatting toolbar with text selected as in your screenshot, you'll see that the B(old) button is "on" (down).
    The same goes for a space at the end of the selection - it doesn't matter whether it's bold or not (or red, or green, or ...)

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

    Re: Font with lreading whitespace (Word 2000)

    And here's something else I don't (yet) understand.
    In the image below I have selected the text "Bold selected" where the first two characters are BOLD and the last five characters are BOLD.
    Executing <pre>selection.font.Bold=false</pre>

    the first time toggles the bolding for the entire selection.
    Executing <pre>selection.font.Bold=false</pre>

    the second time has no effect on the selection.
    Following this,
    Executing <pre>selection.font.Bold=true</pre>

    the first time toggles the bolding for the entire selection.
    Executing <pre>selection.font.Bold=true</pre>

    the second time has no effect on the selection.

    I had expected my "selection.font.Bold=" to force either all-bold, or all-not-bold, not to toggle the bolding.

    (later) using <pre>' rng.Bold = blnBold
    Dim Ch As Range
    For Each Ch In rng.Characters
    Ch.Font.Bold = blnBold
    Next Ch</pre>

    yields my expected result.
    Attached Images Attached Images
    • File Type: jpg 2.JPG (3.7 KB, 0 views)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Font with lreading whitespace (Word 2000)

    When I apply Selection.Font.Bold = False in Word 2002, the entire selection becomes non-bold, and when I apply Selection.Font.Bold = True, the entire selection becomes bold, regardless of how it was set before.
    You can also use Selection.Font.Bold = wdToggle. This is the equivalent of clicking the Bold button or pressing Ctrl+B.

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

    Re: Font with lreading whitespace (Word 2000)

    >you'll see that the B(old) button is "on" (down).
    Thanks, Hans, but not yet.
    I am applying a style csB whose sole characteristic is "Bold".
    The Format, Font dialog box reports that the text is indeed bolded, but the toolbar button for Bold (snapshot) remains unchanged, regardless of the bold status.

    There is a tie-in here, of sorts, for we known that an applied character style can be removed with Ctrl-Space. That is, to some extent Word seems to treat a character style as local formatting when it comes to clearing local formatting.
    I suspect that there is some deep-seated confusion in the code
    Attached Images Attached Images
    • File Type: jpg 3.JPG (8.2 KB, 0 views)

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Font with lreading whitespace (Word 2000)

    As noted, I'm using Word 2002. The Bold button on the toolbar corresponds to the result of VB (except that it doesn't have a "mixed" setting). In your screenshot, the Bold button would be "on" in Word 2002.

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

    Re: Font with lreading whitespace (Word 2000)

    >As noted, I'm using Word 2002
    (That's on my other machine).
    I deleted my Normal template and removed my Traps.dot from the startup folder.
    I fired up Word2003 without my template. The Bold button behaves as you and I would expect.
    I closed Word2003, placed Traps.dot in the startup folder and reloaded Word2003.
    The Bold button, Ctrl-B, Ctrl-Shift-B or Format Font all toggle bold (under my program control) as I had expected, but in no case does the bold button change its status. the Format Font dialog reports the bold setting correctly.

    It seems to me that without my code, Word2003 behaves normally, but when programmatically changing the bold status of a range of characters, the Bold button is not used as a flag.

    It's not a problem for me right now; I'm posting these findings more for curiosity value, in case anyone else is puzzled by Word's behavior.

Posting Permissions

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