![]() |
|
#15
|
||||
|
||||
|
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrPfx As String, StrSfx As String, StrMid As String, StrTmp As String
Dim i As Long, j As Long, k As Long
StrPfx = "\<irf fnf=“": StrSfx = "”/\>"
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(" & StrPfx & "[A-Z]@)[0-9]@" & StrSfx & "-\1[0-9]@" & StrSfx
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
StrTmp = Split(Split(.Text, Replace(StrSfx, "\", ""))(0), "“")(1)
StrMid = StrTmp
For i = 1 To Len(StrTmp)
If Right(StrMid, 1) Like "[0-9]" Then
StrMid = Left(StrMid, Len(StrMid) - 1)
End If
Next
i = CLng(Replace(StrTmp, StrMid, ""))
StrTmp = Split(Split(.Text, Replace(StrSfx, "\", ""))(1), "“")(1)
StrMid = StrTmp
For j = 1 To Len(StrTmp)
If Right(StrMid, 1) Like "[0-9]" Then
StrMid = Left(StrMid, Len(StrMid) - 1)
End If
Next
j = CLng(Replace(StrTmp, StrMid, ""))
StrTmp = ""
For k = i To j
StrTmp = StrTmp & StrPfx & StrMid & k & StrSfx & Chr(11)
Next
StrTmp = Replace(StrTmp, "\", "")
.Text = Left(StrTmp, Len(StrTmp) - 1)
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge Repeat Record a certain number of times
|
stacey_e | Mail Merge | 7 | 07-07-2023 01:27 AM |
| Repeat macro until no more fields | ChrisJ83 | Word VBA | 2 | 01-20-2016 04:55 AM |
Print Format - Repeat Text From a Cell on Multiple Pages
|
ChristopherHughes | Excel | 1 | 12-07-2014 08:31 PM |
How to repeat multiple .jpg's over again in Custom Slide show
|
pbyrescue | PowerPoint | 1 | 04-03-2014 12:40 PM |
| Repeat formula 5 times and repeat? | Jenny345 | Excel | 4 | 06-14-2013 04:37 PM |