Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Auckland, North Island, New Zealand
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detect manual formatting (2000)

    Is there are way, using VBA, to detect whether a paragraph has had manual formatting applied to it?

    (What I am aiming to do is to write a macro which will temporarily change the colour of the text in a paragraph which has manual formatting so that the user can get a quick visual indication as to where she has to do work to remove manual formatting).

    Thanks.

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

    Re: Detect manual formatting (2000)

    It is (sort of) possible to do via VBA - there was a thread about this on the previous incarnation of the Lounge and I recall posting a very cumbersome macro that does this - I'll try to track down the code if I still have it somewhere.

    There were some simpler approaches tried in that thread but if I recall right, they didn't work - maybe someone has come up with a better way in the meantime?

    Gary

  3. #3
    New Lounger
    Join Date
    Nov 2001
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect manual formatting (2000)

    I searched a bit and could not find a quick way of finding out how to determine besides brute programming force if direct formatting is applied. If everything else fails, you always have the option to write a function that would compare the formatting of the selection to the formatting of the style that is applied to the selection.

    Vick

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

    Re: Detect manual formatting (2000)

    I use the appended macro to make manual formatting visible.

    It creates a new document.
    In this document, I define all paragraph styles to look just like "Normal", and all character styles to look like the "default paragraph font".
    When this is done, all manual formatting is obnoxiously visible, and easy to clean up.

    When I'm done, I can either paste the text back into the old document, or copy the old style definitions to the new doc with the organizer.

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

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Detect manual formatting (2000)

    Klaus,

    I'm not sure if all direct formatting would be visible or at least perhaps not obnoxiously so. I didn't try your macro but gave some thought to the problem when I saw the original posting.

    For example, suppose I have a para style with 6 points of spacing after it and add 1 pt manually. Not sure the eye would catch that. Probably some similar analogies for characters - like character spacing.

    Is there a way to capture the result of the SHIFT+F1 key, which will also show any direct formatting? For example, loop thru each para in the doc, "apply" SHIFT+F1 to it, and see if the callout shows any direct formatting? I recognize this would be a big problem to check each character to see if there's direct formatting applied to a specific character. But I didn't think it would be too bad on a para basis (assuming >1 char per para). I wasn't even sure if the original post was limited to direct formatting to para styles or included char styles as well. Your macro obviously works for both but it may not be very "visible".

    Fred

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

    Re: Detect manual formatting (2000)

    Hi Fred,

    I don't think the objections you raised apply:
    <hr>For example, suppose I have a para style with 6 points of spacing after it and add 1 pt manually. Not sure the eye would catch that.<hr>
    If the style had 6 pt spacing after, and you added 1 pt manually, the paragraph has 7 pt space after manual formatting. Since "Normal" has 0 pt space after, you see the difference (7 pt).

    <hr>Probably some similar analogies for characters - like character spacing.<hr>
    That is true, but manual formatting that is (nearly) invisible doesn't matter much most of the time.
    Of course you might have invisible manual formatting that is worth keeping. If somebody slaved away for days formatting a dictionary with different languages, it would be a shame to remove that.
    But usually after I have cleaned up the "obnoxiously visible" manual formatting, I select all and hit Ctrl-spacebar and Ctrl-Q to get rid of the invisible formatting <img src=/S/toilet.gif border=0 alt=toilet width=24 height=26>.


    Just give the macro a try.

    If I find the time someday, I'll try something along the lines of your suggestion. I've sometimes thought about a macro that would analyse the manual formatting, and make suggestions to fix it (so you don't have to check each individual formatting: something like AutoFormat, but functional) but that would require lots and lots of code, and I'm not too anxious to write it. I try to train and help most authors that send me manuscripts. Now I don't get that many documents with manual formatting any more.
    So don't hold your breath waiting for a better macro from me <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

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

  7. #7
    Star Lounger
    Join Date
    Feb 2001
    Location
    Auckland, North Island, New Zealand
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detect manual formatting (2000)

    Thanks Klaus, and others, for your comments on this issue.

    I'd still like to find the equivalent of: If ParaHasManualFormatting() Then

    Surely there must be a function which is inbuilt into to the main programme which does just this job as it knows how to accurately determine whether we have applied manual formatting and thereby ask us whether we want to apply the new formatting to the style or revert to the style.

    Wouldn't there therefore be an API call or similar we could use to access this functionality? Are there any from MSWord programming team on this forum?

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

    Re: Detect manual formatting (2000)

    Hi again,
    <hr>Are there any from MSWord programming team on this forum?<hr>
    - if there were, they took one look here and <img src=/S/flee.gif border=0 alt=flee width=25 height=25>.

    Seriously, there probably isn't any inbuilt function. Capturing the results of the "What's This?" dialog would seem a good idea, but I don't think you can access the results of that dialog programatically.

    I don't think an API call would do the trick either. It is possible to write a brute force macro to do this (as Klaus was implying), and as mentioned in my previous post, I did write a macro that did this, a couple of years ago. It was posted on the old Lounge and is now lost - I've looked on my home PC and no luck (still have to look at work). The other possibility is that I might have a hard copy of it somewhere but it is a very long macro to have to retype! I'll post back if I can track it down somehow....

    Gary

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

    Re: Detect manual formatting (2000)

    Hi again,

    Couldn't find the original code so have recreated a stripped-down version - see the attached .txt file.

    This one loops through each paragraph in the document, and for each paragraph, tests each character until it finds one with manual formatting.

    If manual formatting is found, that paragraph is highlighted. This could also be adapted to highlight the individual characters rather than the paragraphs.

    This stripped-down version only tests for five common properties (bold, italic, underline, font name and font size), but it provides a template for how you can test for as many properties as you want

    To test for all possible properties would require a lot of code and would probably run very slowly. One approach that was suggested to me last time around would be to do the test in two passes - first do a function that tests for only the most common properties. Only if no hits are found, then continue with the second function that would be more exhaustive.

    Gary
    Attached Files Attached Files

Posting Permissions

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