View Single Post
 
Old 04-01-2010, 05:37 AM
pochtara pochtara is offline Windows XP Office 2007
Novice
 
Join Date: Apr 2010
Posts: 1
pochtara is on a distinguished road
Post Issue skipping characters by Regular Expressions in Word

When using Regular Expression search using VBA script in Excel to search Word document, "-" character in the word document gets skiped (substituted with "" empty character).
Here is the string in Word: <DE4.0><SWR4.4.l‑CE6:A>
Here is the snipet of VBA code used:
With Selector.Find
.text = "\<DE?*^13"
.Replacement.text = ""
.Forward = True
.Wrap = wdFindzz
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With

The search find the string in the Word and here is the resulting string in the VBA: <DE4.0><SWR4.4.lCE6:A>

As you can see the "-" hyphen character is missing in the resulting string and I can't understand why and how to fix it.

Can someone help me with this?
Thanks
Alex

P.S. I've attached the Word and Excell document that I'm using if someone wants to try it.
The VBA macro in Excel that does this work called DEExtract. Put a breakpoint on the line 250 ( While Selector.Find.Execute) and after that Selector.text will show the search result. To execute it, click on the "Import Design Elements" on the Design Elements tab and then select the word document.
Reply With Quote