Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-26-2011, 04:32 AM
macropod's Avatar
macropod macropod is offline Need help on macro for looping Windows 7 32bit Need help on macro for looping Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Hi Kilosub,



Try:
Code:
Sub StatementReformatter()
Dim StrFind As String, StrRep As String
Dim myRange As Range, i As Long
StrFind = "[ ]{8}[0-9]{1,2}/[0-9]{2}/[0-9]{2}(^13[ ]{8}[0-9]{10}^13)|(    BONUS POINTS AS AT)"
StrFind = StrFind & "|(    Your card will expire on[!^13]{1,}^13)|(    Dear valued cardmember[!^13]{1,}^13)"
StrFind = StrFind & "|(    Collection date)|(    Expiry date of rebate voucher :)([!^13]{1,}^13)"
StrFind = StrFind & "|(    For enquiries[!^13]{1,}^13)|(    I acknowledged receipt[!^13]{1,}^13)"
StrFind = StrFind & "|(    and / OR[!^13]{1,}^13)|(    Signature:[!^13]{1,}^13)|(    IC/ Passport No:[!^13]{1,}^13)"
StrRep = "^m^p^p^p^p^p^p\1^p^p|^p^p^p^p\1|^p\1|^p\1^p|^p\1|^p\1#\2^p|^p\1^p|^p\1^p|^p^p\1^p^p|^p\1^p|^p\1^p"
With ActiveDocument
  For i = 0 To UBound(Split(StrFind, "|"))
    Set myRange = .Range
    With myRange.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchAllWordForms = False
      .MatchSoundsLike = False
      .MatchWildcards = True
      .Text = Split(StrFind, "|")(i)
      .Replacement.Text = Split(StrRep, "|")(i)
      .Execute Replace:=wdReplaceAll
    End With
  Next
  With .Range.Find
    .Text = "(Your card will expire on[!^13]{1,})"
    .Replacement.Text = "\1"
    .Replacement.Font.Bold = True
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
    .Text = "#([0-9]{1,2} [JFMASOND][anuryebchpilgstmov]{2,8} [12][0-9]{3}.)"
    .Execute Replace:=wdReplaceAll
  End With
  With .Characters.First
    .Delete
    .Delete
  End With
End With
Set myRange = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 04-26-2011, 08:25 PM
kilosub kilosub is offline Need help on macro for looping Windows XP Need help on macro for looping Office 2003
Novice
Need help on macro for looping
 
Join Date: Apr 2011
Posts: 24
kilosub is on a distinguished road
Default

Hi Macropod,

Thanks for the code, I don't understand the coding at all... . Anyway I test run on 60,000Kb data. Error shows "The document is too large to save. Delete some text before saving". Should I ignore the message or it's just limitation for ms words. Total are 384 pages.


Btw, after print out, found the 1st data line is at 6.9cm measure from the top end of the page can you bring it to 2.9cm, so that all data can be in 1 page.

Thanks a lot.

Cheers!!

Kilosub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping Question Steve B PowerPoint 0 01-19-2011 10:44 AM
Looping video tomasball PowerPoint 0 10-30-2010 02:38 PM
Unbreakable looping Dixon Outlook 0 09-23-2009 02:10 PM
Need help on macro for looping How to Advance from Looping SWF Animation? BSquared18 PowerPoint 1 07-04-2009 01:56 PM
Looping though Custom Properties in VBA suekay Misc 0 05-19-2006 06:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:45 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