Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Thanked 0 Times in 0 Posts

    Sample macro (Word 97 SR2)

    I was wondering if someone already created a macro to delete 2 blank spaces at the beginning of every line of the entire document. I tried search and replace but it also removed the spaces after the periods.



  2. #2
    Star Lounger
    Join Date
    Jan 2001
    mountains, North Carolina, USA
    Thanked 0 Times in 0 Posts

    Re: Sample macro (Word 97 SR2)

    i know less than nothing about writing macros.....but.....try this

    do a search and replace
    search for a paragrah marker....followed by white space
    this will find two....three ....or any number of spaces

    you use ^p to find a paragraph.....and ^w for white space
    then you replace with ^p followed by one space
    this should find all the extra spaces at the start of a new paragraph but not at the start of a sentence.

    Good luck
    Larry <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    West Long Branch, New Jersey, USA
    Thanked 9 Times in 7 Posts

    Re: Sample macro (Word 97 SR2)


    As Larry suggested, I think you probably don't need a macro - sorry to disappoint.

    I was going to suggest the same thing Larry did. But I also realized that the 2 spaces at the beginning of a line may follow something other than a paragraph mark, eg, a section or page break. This may not be the case since getting spaces at the beginning of a line sometimes is a result of bringing a text file, like email, into Word (if that's what you're working with). If that's true, then you probably don't have any section or page breaks to worry about and Larry's suggestion is slightly simpler than the below.

    With the suggestion here, as well as Larry's, you only have to worry about the very first line since the 2 spaces there don't follow anything.

    So here's my 2 cents:
    Use Find/Replace
    1. click on the more button in the lower right of the dialog box - this will get you some extra items.
    2. check the Use Wildcards box (word 97 and beyond); or Use Pattern Matching (word 95 and before?)
    3. For Find What, type
    ([!.])x{2,} where the x is really a space but I didn't want you to miss it
    4. For Replace With, type

    What is happening in Find What is:
    - you are defining an Expression with the ( ); see Replace With for why this is needed
    - inside the expression, you are matching for any character OTHER than a period. That is what the exclamation does - says OTHER than. You could also put other characters inside the brackets after the !
    - after the ( ), you type a space (not the x as noted above)
    - {2,} says to find cases where the character before the {} occurs at least 2 times (which, with a space before the {}, is the equivalent of Larry's ^w but you can't use ^w when using Wildcards)

    With the Replace With:
    - 1 says to just use the first Expression that you defined in the Find What box for the Replace With

    So this replaces 2 or more spaces that follow anything that's not a period with the anything.

    hope this helps.


Posting Permissions

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