D
demyan
Hi,
I have a macro that goes through a document and selects (and places in a new document) words written in red; please see below. (I use a Range object, and shrink range-to-be-searched after each found instance). As I discovered, the macro - its 'Range.MoveStart' bit, I believe - does not work when a word in red is found within a table. Could someone please tell me what this is about?
Thank you very much
PS. I added an iteration-counter j in the code below in order to break the infinite loop that I get without it
Sub extract(
If MsgBox("This macro will select and place in a new Word document words written in red", vbOKCancel, "Extract") = vbCancel The
En
End I
Dim rSch, rRes As Rang
Set rSch = ActiveDocument.Rang
Set rRes = rSch.Duplicat
Dim newDoc As New Documen
newDoc.Content.InsertAfter Text:=vbC
j =
D
With rRes.Fin
.ClearFormattin
.Font.Color = wdColorRe
.Format = Tru
.MatchWildcards = Tru
.Text = "<*>
.Execut
End Wit
If rRes.Find.Found And j < 10 The
j = j +
rRes.Selec
newDoc.Content.InsertAfter Text:=Selection.Text & vbC
rRes.MoveStart wdWor
rRes.End = rSch.En
End I
Loop Until Not rRes.Find.Foun
End Su
I have a macro that goes through a document and selects (and places in a new document) words written in red; please see below. (I use a Range object, and shrink range-to-be-searched after each found instance). As I discovered, the macro - its 'Range.MoveStart' bit, I believe - does not work when a word in red is found within a table. Could someone please tell me what this is about?
Thank you very much
PS. I added an iteration-counter j in the code below in order to break the infinite loop that I get without it
Sub extract(
If MsgBox("This macro will select and place in a new Word document words written in red", vbOKCancel, "Extract") = vbCancel The
En
End I
Dim rSch, rRes As Rang
Set rSch = ActiveDocument.Rang
Set rRes = rSch.Duplicat
Dim newDoc As New Documen
newDoc.Content.InsertAfter Text:=vbC
j =
D
With rRes.Fin
.ClearFormattin
.Font.Color = wdColorRe
.Format = Tru
.MatchWildcards = Tru
.Text = "<*>
.Execut
End Wit
If rRes.Find.Found And j < 10 The
j = j +
rRes.Selec
newDoc.Content.InsertAfter Text:=Selection.Text & vbC
rRes.MoveStart wdWor
rRes.End = rSch.En
End I
Loop Until Not rRes.Find.Foun
End Su