• 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
Source.Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
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
Loop
End With
Selection.HomeKey Unit:=wdStory
Target.Activate
End Sub
0
TheoRichel
Asked:
TheoRichel
1 Solution
 
GrahamSkanRetiredCommented:
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:

"[+0-9A-z._-]{1;}\@[A-z.]{1;}"
0
 
TheoRichelAuthor Commented:
Spot on, Thanks!
0
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