Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Mar 2008
    Location
    New York, New York, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,
    I have a macro set to find double spaces within text, only if "Arial" is applied.

    When I do this manually, it works fine.

    But when I try to run the macro below, it doesn't find the text for some reason.

    The only difference I can see is that when I run the macro, Word seems to be looking for "(Default) Arial", whereas when I run in manually, it's just searching for "Arial". I have no idea why "(Default)" gets inserted into the formatting search or why that would make a difference.

    Any ideas?

    Thanks!
    John

    Do
    Selection.HomeKey unit:=wdStory
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = " "
    .Replacement.Text = " "
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .Font.name = "Arial"
    .Execute Replace:=wdReplaceAll
    End With
    Loop Until Selection.Find.Execute = False

  2. #2
    Lounger
    Join Date
    Feb 2005
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a similar problem. When I edit a document, I highlight changes I make. When the job is finished, I look for any highlighting. Word does not always find it and I have to look manually.

    Allan

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='johnwangel' post='771961' date='23-Apr-2009 10:15']Do
    Selection.HomeKey unit:=wdStory
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = " "
    .Replacement.Text = " "
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .Font.name = "Arial"
    .Execute Replace:=wdReplaceAll
    End With
    Loop Until Selection.Find.Execute = False[/quote]
    Several observations:
    1. You are searching for a single space in Arial and replacing it with a single space in Arial. Therefore nothing seems to be happening.
    2. You have an endless loop as a consequence of the foregoing.
    Regards
    Don

  4. #4
    New Lounger
    Join Date
    Mar 2008
    Location
    New York, New York, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='AllanBrown' post='771965' date='23-Apr-2009 15:42']I have a similar problem. When I edit a document, I highlight changes I make. When the job is finished, I look for any highlighting. Word does not always find it and I have to look manually.

    Allan[/quote]

    Hi Allan,

    I use this macro to search for highlighting and it's been infallible so far. It's pretty basic.

    With Selection.Find
    .ClearFormatting
    .Text = ""
    .Highlight = True
    .Forward = True
    .Wrap = wdFindStop
    .Execute
    End With

    Is it possible you have text left in the "Find" box, preventing it from performing the search properly?

    John

  5. #5
    New Lounger
    Join Date
    Mar 2008
    Location
    New York, New York, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='wdwells' post='771971' date='23-Apr-2009 16:06']Several observations:
    1. You are searching for a single space in Arial and replacing it with a single space in Arial. Therefore nothing seems to be happening.
    2. You have an endless loop as a consequence of the foregoing.
    [/quote]

    No, the actual macro searches for 2 spaces and replaces with 1. Maybe that's a consequence of the copy/paste that makes it appear to be one space.

    There is no endless loop. When I step through the macro, I can see that it doesn't find anything, and doesn't even loop once.

    Here's a sample of the text I'm searching, which does contain several examples of double spaces:

    postsecondary education to graduation on a national basis. Such a database, if created, could finally address the fact that most students these days attend more than one institution before earning a degree. True, forty-two of the fifty states maintain unit record databases and are thus able to keep track of folks within their own boundaries. But few of them have established data exchange arrangements with neighboring states and most do not contain information about private college enrollment. The federal proposal therefore made a great deal of sense. But it hit a wall. Amid arguments advanced

    Thanks.

    NOTE AFTER POSTING: This site does automatically delete the double spaces. The text above should show 2 spaces after each period.

  6. #6
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    I suggest that you carefully examine the text which you are searching and ensure that font name is 'Arial' and not one of the variations such as 'Arial Narrow'
    Regards
    Don

  7. #7
    New Lounger
    Join Date
    Mar 2008
    Location
    New York, New York, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='wdwells' post='771978' date='23-Apr-2009 16:38']I suggest that you carefully examine the text which you are searching and ensure that font name is 'Arial' and not one of the variations such as 'Arial Narrow'[/quote]

    Thanks for the suggestion. Of course, I have already done that.

    I found that if I use

    .Font.NameAscii = "Arial"

    rather than

    .Font.Name = "Arial"

    the problem is resolved.

    Does anyone have any advice on the consequence of using NameAscii? It appears that it will only alter text within the ASCII set. In this case that's not a problem. Any other issues I should be aware of?

    Thanks,
    John

  8. #8
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='johnwangel' post='771980' date='23-Apr-2009 11:45']Thanks for the suggestion. Of course, I have already done that.

    I found that if I use

    .Font.NameAscii = "Arial"

    rather than

    .Font.Name = "Arial"[/quote]Thanks for the feedback John; another arrow for my quiver.
    Regards
    Don

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='johnwangel' post='771977' date='23-Apr-2009 08:15']NOTE AFTER POSTING: This site does automatically delete the double spaces. The text above should show 2 spaces after each period.[/quote]
    Browsers magically collapse whitespace; that is normal. To preserve the appearance of code, use the BBCode code tags. They can be inserted using the button that looks like scroll, or by typing [code] and [/code] around your code.

    Code:
    One space
    Two  spaces
    Three   spaces, etc.

  10. #10
    New Lounger
    Join Date
    Mar 2008
    Location
    New York, New York, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='jscher2000' post='771998' date='23-Apr-2009 18:52']Browsers magically collapse whitespace; that is normal. To preserve the appearance of code, use the BBCode code tags. They can be inserted using the button that looks like scroll, or by typing [code] and [/code] around your code.

    Code:
    One space
    Two  spaces
    Three   spaces, etc.
    [/quote]

    Ah. Thanks!

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    See NameAscii Property for information about the NameAscii property.

Posting Permissions

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