![]() |
#4
|
||||
|
||||
![]()
This should get you started. Note that your concept might miss the last entry if it doesn't end with a # (which in your sample code appears to be a start point rather than a bracketing)
Code:
Sub Macro1() Dim aRng As Range, sFound As String Set aRng = ActiveDocument.Range With aRng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "#*#" .Forward = True .Wrap = wdFindStop .Format = False .MatchWholeWord = False .MatchWildcards = True Do While .Execute = True aRng.MoveStart Unit:=wdCharacter, Count:=1 aRng.MoveEnd Unit:=wdCharacter, Count:=-2 If Len(aRng.Text) > 32766 Then Debug.Print "Oversize Block starting: " & aRng.Paragraphs(1).Range.Text Else 'Do something with the found content MsgBox aRng.Text End If aRng.Collapse Direction:=wdCollapseEnd If aRng.End = ActiveDocument.Range.End Then Exit Do Else aRng.End = ActiveDocument.Range.End aRng.Select End If Loop End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ubrielbryne | Word VBA | 1 | 02-25-2019 11:15 AM |
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge | Berryblue | Mail Merge | 1 | 11-13-2014 05:36 PM |
![]() |
JUST ME | Word VBA | 4 | 03-25-2014 06:56 AM |
![]() |
MJP143 | Excel | 1 | 02-11-2013 05:07 AM |
![]() |
tinfanide | Excel Programming | 2 | 06-10-2012 10:17 AM |