• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

What is wrong with this MS Word macro

I have copied this macro from somewhere on the net to collect emailaddresses from a Word file. It refuses to run however because of "Error 5560 during execution. The text in the search box contains an invalid selection criterium" (My translation from Dutch). Can anyone tell me what is wrong?
This is the macro:
Sub ExtractEmailadressen()
' ExtractEmailadressen Macro
' Macro gemaakt op 4/11/2011 door TheoRichel
Dim Source As Document, Target As Document, myRange As Range
Set Source = ActiveDocument
Set Target = Documents.Add
Selection.HomeKey Unit:=wdStory
With Selection.Find
Do While .Execute(findText:="[+0-9A-z._-]{1,}\@[A-z.]{1,}", _
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set myRange = Selection.Range
Target.Range.InsertAfter myRange & vbCr
End With
Selection.HomeKey Unit:=wdStory
End Sub
1 Solution
The wildcard Find seems to be sensitive to the regional settings settings for decimal formatting. Try using a semicolon (;) instead of the comma (,) in the pattern, thus:

TheoRichelAuthor Commented:
Spot on, Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now