Results 1 to 3 of 3

Thread: Pattern Error

  1. #1
    Lounger
    Join Date
    Aug 2013
    Posts
    45
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Pattern Error

    Hi,
    Why i am getting this Run-time error '5560'
    The Find What text contains a Pattern Match expression which is not valid.


    THE REGISTERED TOWN A PL-LN. HSGSOC LTD
    City Cross Road, Off. Liberty Street, Kulan (North), Sydne-6747454
    [Plan. No. xxxxx/Bl/HSOC/(TV)/18584/2014-15]
    Bill No. 1102341.........................space............. ....................................Bill Date: 01/12/2014

    1/-/777, SAM WORKS LTD.
    Output from Macro.

    777
    THE REGISTERED TOWN A PL-LN. HSGSOC LTD
    City Cross Road, Off. Liberty Street, Kulan (North), Sydne-6747454
    [Plan. No. xxxxx/Bl/HSOC/(TV)/18584/2014-15]
    Bill No. 1102341.........................space............. ....................................Bill Date: 01/12/2014

    1/-/777, SAM WORKS LTD.
    Code:
    Sub Numbers()
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = _
                "(^m)(*Bill Date: [0-9]{1,2}/[0-9]{1,2}/[0-9]{4}^13[!^13]@/)([0-9]@)(,[!^13]@^13)"
            .Replacement.Text = "\1\3\2\3\4"
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchKashida = False
            .MatchDiacritics = False
            .MatchAlefHamza = False
            .MatchControl = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = True
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    Attached Files Attached Files

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    I'm not seeing any vba errors when I run it on Word 2007.

    Of course it is also not finding any hits in your sample document because there are no section breaks.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Depending on your regional settings, you may need to change both instances of {1,2} to {1;2}.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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