Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Searching for a specific Format (VBA/Word/2000 SP-3)

    Oh Frustration
    I recorded the following code while searching for any character with the Symbol font.
    <pre>Sub Macro23()
    '
    Selection.Find.ClearFormatting
    With Selection.Find
    .Text = "^?"
    .Replacement.Text = " "
    .Forward = True
    .Wrap = wdFindAsk
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    End Sub
    </pre>


    During the recording phase I did indeed find the first instance of the Symbol font; however when running the macro, there is no recognition of any format requirements. I should know this; but I don't.
    How do I code the format information for a Find activity?
    TIA
    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Searching for a specific Format (VBA/Word/2000 SP-3)

    Try adding

    <code> .Font.Name = "Symbol"</code>

    to your list.

    StuartR

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

    Re: Searching for a specific Format (VBA/Word/2000 SP-3)

    Stuart has already posted a suggestion. You have bumped into one of the major weaknesses of the macro recorder: some actions get recorded incompletely, or even not at all. There are also actions that get recorded incorrectly - everything will go smoothly while recording, but the resulting code is invalid.
    Still, the macro recorder is a handy tool in many situations to get a first idea of the code you need. Just don't trust it blindly.

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Searching for a specific Format (VBA/Word/2000 SP-3)

    Stuart
    Thanks for the speedy response.

    Hans
    I'm sufficiently long in the tooth, that the only thing I trust blindly is the dear lady I've been married to for fifty years.

    Thanks again to both.
    Regards
    Don

Posting Permissions

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