Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  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

    Code: Sub FillLikePhil()

    <pre>Sub FillLikePhil()
    ' Ah, what the heck!
    ' Key any text into a document, Ctrl-Home, then run this macro. Cute eh?
    ' For a good time replace all the text with spaces (ascii 32)
    ' For an even better time, use ShowAll.

    While Not Selection.End = ActiveDocument.Content.End - 1
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    With Selection.Font
    .ColorIndex = 16 * Rnd()
    .Animation = 6 * Rnd()
    End With
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Wend
    End Sub
    </pre>


  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: Sub FillLikePhil()

    Ouch. That was painful.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Code: Sub FillLikePhil()

    Might be worth mentioning the antidote:

    Control+A
    Control+Spacebar

    Hey, my initials are "GIF" (not GPF like Woody said) - wanna write a "GIFLikeGIF" macro? <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

  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: Code: Sub FillLikePhil()

    Not allowed. Doctor's orders. I have a mildly infected throat, constricted passages, difficulty swallowing, flu-like (mild) symptoms. I've been told eat well, drink lotsa fluids. Rest. And NEVER look a Gif, hoarse in the mouth.

  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: Code: Sub FillLikePhil()

    Glad you liked it!



    >Control+A
    Control+Spacebar


    Ah. You SPOLIED it for everyone (grin!)



    Hey! How useful is a macro that removes all local character formatting (as in your steps above) *but* leaves characters styled with a character style in place?

  6. #6
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: Sub FillLikePhil()

    You know, I've often thought of writing one myself. Don't get me started on the CTRL+Shift functionality <g>. You need to be able to nuke manual formatting but the notion of punishing folks that properly format a document using character styles irks me no end.

    If you decide to crank out some code, I'd definitely check it out.

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Code: Sub FillLikePhil()

    Hi 2(Chris):

    Maybe this is more appropriate for the Word forum, but can you offer a compelling argument for using character styles for simple things like bold or italic?

    I'm a devout believer in paragraph styles (and use of these is strictly enforced in our organization), but fail to see the benefit of character styles for things like bold or italic. Or perhaps better put: do the benefits outweigh the inconvenience and impracticality of getting users to give up on Control B or I (or the buttons)? - implementing character styles for these just seems quixotic....

    Gary

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

    Re: Code: Sub FillLikePhil()

    You'll find this on my Formatting toolbar menu if you download Under.zip from the downloads page.

    <pre>Public Sub cmd_ResetFormattingToStyles()
    ' Procedure : cmd_ResetFormattingToStyles
    ' Description: Remove all local formatting from the active document.
    ' By: Chris Greaves Inc.
    ' Inputs: None.
    ' Returns: None.
    ' Assumes: Nothing
    ' Side Effects: None.
    ' Tested: By a call from the user.
    ' Method: For each style in the document build a table.
    ' Column1 - Style name
    ' Column2 - Range start
    ' Column3 - Range end
    ' Replace local formatting throughout the document.
    ' Apply styles to all ranges from the table
    ' Build the table of styles.
    Dim strStyles() As String
    ReDim strStyles(0)
    ' Build an array of all styles in the document
    Call lngStylesInDoc(strStyles, ActiveDocument)
    ' Discard those styles not actually in use in the document.
    Call lngDiscardInValidStyles(strStyles, ActiveDocument)
    Dim varStyleRanges()
    ReDim varStyleRanges(2, 0)
    ' For each style in use, record its range-of-use
    Dim i As Integer
    For i = 0 To UBound(strStyles)
    Call AddToTable(varStyleRanges, strStyles(i))
    Next i
    ReDim Preserve varStyleRanges(2, UBound(varStyleRanges, 2) - 1)
    ' Clear local formatting.
    Selection.WholeStory
    Selection.Font.Reset
    ' Apply styles from the table.
    Dim myRange As Range
    For i = 0 To UBound(varStyleRanges, 2)
    Set myRange = ActiveDocument.Range(Start:=varStyleRanges(1, i),_
    End:=varStyleRanges(2, i))
    myRange.Style = varStyleRanges(0, i)
    Next i
    End Sub
    </pre>


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

    Re: Code: Sub FillLikePhil()

    I know you were addressing this to the OTHER Chris, but since I got here first ..... (grin!)


    I assign my character style csB to the shortcut key Ctrl-B. Ya gotta problem wid dat?

    I have csU, csI, csUB, csIB, csUI, csUIB.

    If ever I think that the underlining is getting out of hand in a document, I just change the style. The others are still doing Ctrl-A and realising that they've forgotten where they had underlined ...

    It's late at night, but i feel a deep philosophical thought coming on that there CAN'T be any differenc ebetween using character styles and paragraph styles. I mean in actuallty USING them. After all, whether you format locally or with character styles, you still have to select the characters, right?

    Character styles cost no more and give you flexibility, such as marching-black-ants etc.

  10. #10
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Code: Sub FillLikePhil()

    If you prefer, individually, to set yourself up with character styles than hey whatever makes you happy. My issue relates more to trying to enforce the use of these in a business organization - fuggedaboudit...

    Before I switched to Word, I worked exclusively on FrameMaker for a few years. In Frame we did enforce the use of character styles - it's a little hazy now, but I do recall reading up on the difference between character styles and manually applied ones then: at least with certain types of fonts, there actually was a difference: Control+I (or clicking on the Italic button) would make the application take the regular font and slant it, whereas applying the Italic font style told the app to use the italic character set that came with that font - I'll have to go back and track down the source of that one!

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

    Re: Code: Sub FillLikePhil()

    >whereas applying the Italic font
    style told the app to use the italic character set that came with that font


    OK. But you can't have your cake and eat it too.

    If the argument about "How the basic user applies formatting - don't make it too difficult" applies, then it's going to be the same user who says "built-in italics, fabricated italics, who cares? It's slanted". Right?

    I think if there is a choice between a "Word-has-slanted-TNR for you" and a "Word has found a better front than a slanted TNR, it's called SlantedTNR", and if that choice is important, then you are dealing with professional fonters who ought to be using the proper tools.

    And if you say that character styles are important, then they ought to do that. I know they never will do what we tell/want 'em to do.


    (later)

    Again, if the fabrication of italic is potentially important, all the more reason to use a character STYLE which we know lends itself so easily to future standardization. When your boss says "enough with the SlantedTNR", you breathe a sigh of relief and say "Thank Word for character styles (click, click, drop-down, click, OK)".

  12. #12
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Code: Sub FillLikePhil()

    The subtle distinction in results was something that may have mattered in a typesetting environment, but in the typical word processing environment that is Word's arena, discussion of this would elicit a "huh?" or worse.

    A typical word-processed legal document, for instance, is unlikely to contain anything fancier than bold, italic or underscore, and no one is giving out points for style (or styles). Rare is the boss who can even tell you the difference between TNR and Arial.

  13. #13
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: Sub FillLikePhil() and Character Styles

    <snip> implementing character styles for these just seems quixotic....
    <snip>

    <Climbing on to Rocinante>

    Nearly. I work with Technical Writers. New writers and many experienced writers often don't fully appreciate the importance of *every* element of a document being based on a style. I have often seen the rollout of a template that would standardize the appearance of a particular type of document. Within a year they all look slightly different.

    Those Bold, Italic, and Underline buttons are the first loss in the battle to standardize. Authors see them and get the notion that they're free to format. "Hey, I can apply bold! Well, I know I'm not supposed to muck around with the styles so I'll just go to Format>Paragraph and work my magic on this paragraph."

    In my current position, I took a template in another application (please don't ask) and made a Word template. I removed all formatting options from toolbars *and* menus. I gave them a new menu with the styles to be used in the documents and also created keyboard shortcuts. When I rolled the thing out, I expected a hue and cry about the loss of autonomy. Actually, the writers loved it. It removed all the guesswork.

    At another job, I had the unenviable task of restoring manually formatted docs to the format originally intended by the template. Fortunately, the template creator had used character styles and some of the documents used them. The logical thing would be to remove all manual formatting and go on from there. I could not do that because Selection.Font.Reset also resets character styles. Hence the reason for my original reply to this post.

    I see that others have also raised the issue that using character styles makes it easy if you need to change the formatting for those styles.

    Perhaps I'm a bit fascistic about it. But, no well-trained Technical Writer should ever apply manual formatting to a properly designed template. Heaven forfend if I find a writer using carriage returns to create space after!

    Regards,

    The Other Chris <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

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

    Re: Code: Sub FillLikePhil() and Character Styles

    > because Selection.Font.Reset also resets character styles

    I've felt for a lomng time that this is a bug, rather than a design feature.

    I find nothing in the help files to warn me that it clobbers character styles, "Removes manual character formatting (formatting not applied using a style)" is the text, and I can think of no reason for it having to do so.

    It MIGHT make sense to have several commands ResetAllManual, RsetManualFromParagraphStyled, ResetManualFromCharacterStyled, etc.


    >Perhaps I'm a bit fascistic about it.

    Not really. It amkes no sense at all to employ character styles and then avoid them. The ONLY benefit of local formatting is to people like me who go around cleaning up non-standard documents.

  15. #15
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: Sub FillLikePhil() and Character Styles

    Warning: Hearsay coming up.

    I have heard tell in another (also distinguished) forum that the folks in Redmond consider the feature of Font.Reset slamming character styles as by design. This in response to repeated requests to stop it and in spite of the fact that they don't tell you about it.

Page 1 of 2 12 LastLast

Posting Permissions

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