Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2019, 03:28 PM
totoMSOF totoMSOF is offline Regex over 700 matches in a long doc Windows 7 64bit Regex over 700 matches in a long doc Office 2010
Novice
Regex over 700 matches in a long doc
 
Join Date: Mar 2019
Posts: 11
totoMSOF is on a distinguished road
Default

It seems to work well for the sample I tried, with a third of my whole doc and the sumary, but it didn't work with the entire doc (e.g. too long: more than 5 minutes without stopping).


But I'll make another try later, and I'll come back after studying the code because I guess I'll have many questions...

Thanks for the help.
Reply With Quote
  #2  
Old 03-03-2019, 03:38 PM
macropod's Avatar
macropod macropod is offline Regex over 700 matches in a long doc Windows 7 64bit Regex over 700 matches in a long doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by totoMSOF View Post
It seems to work well for the sample I tried, with a third of my whole doc and the sumary, but it didn't work with the entire doc (e.g. too long: more than 5 minutes without stopping).
Taking more than 5 minutes is hardly evidence of "it didn't work". Inserting a DoEvents command in the loop and triggering it periodically might speed things up, though, by giving Word some breathing space for housekeeping. For example:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, StrNt As String
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "\(\[[!\(\[]@\][!\(]@\)"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    i = i + 1
    StrNt = .Text
    .Text = vbNullString
    .Footnotes.Add .Duplicate, , StrNt
    If i Mod 50 = 0 Then DoEvents
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
regex, replace



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex over 700 matches in a long doc Using VB Regex feature, I tried to replace 'the' and 'this' with 'that' but got screwed abdan Word VBA 3 01-18-2019 09:38 PM
How to compare 2 Excel sheets for 100+ matches? dylansmith Excel 5 05-22-2017 09:09 PM
Macro help regex subspace3 Word VBA 1 10-15-2014 09:53 AM
Regex over 700 matches in a long doc Convert RegEx to Word (Devanagari Font Find/Replace) gasyoun Word VBA 9 04-12-2013 04:15 PM
Regex in Word: Replaced strings are in disorder chgeiselmann Word 0 04-26-2009 11:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft