W
Winston
Hello Everyone,
I have a document which I would like to search for particular text
beginning and ending with special characters and then insert at the
end of the text a Table of Authorities field code with the text found.
So far the following code finds the text but the field code is
inserted at the curser position where I start the macro and not after
the point where it finds the text.
eg. Text in Word document:
..yy.Text to go into table of authorities.e.
I would like the macro to do this:
..yy.Text to go into table of authorities.e.{ TA \l "Text to go into
table of authorities" \c 1 }
Any help in pointing out what is wrong with this code would be greatly
appreciated!,
Winston
Sub Macro1main()
'
' Macro1main Macro
'
'
Dim oRng3 As Word.Range
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[.][y][y][.]*[.][e][.]"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
While .Execute
oRng.Start = oRng.Start + 4
oRng.End = oRng.End - 3
insertTOAmacro oRng
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
Sub insertTOAmacro(ByVal oRng2 As Range)
ActiveDocument.TablesOfAuthorities.MarkCitation _
Range:=Selection.Range, ShortCitation:=Selection.Range.Text, _
LongCitation:=oRng2.Text, Category:=1
End Sub
I have a document which I would like to search for particular text
beginning and ending with special characters and then insert at the
end of the text a Table of Authorities field code with the text found.
So far the following code finds the text but the field code is
inserted at the curser position where I start the macro and not after
the point where it finds the text.
eg. Text in Word document:
..yy.Text to go into table of authorities.e.
I would like the macro to do this:
..yy.Text to go into table of authorities.e.{ TA \l "Text to go into
table of authorities" \c 1 }
Any help in pointing out what is wrong with this code would be greatly
appreciated!,
Winston
Sub Macro1main()
'
' Macro1main Macro
'
'
Dim oRng3 As Word.Range
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[.][y][y][.]*[.][e][.]"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
While .Execute
oRng.Start = oRng.Start + 4
oRng.End = oRng.End - 3
insertTOAmacro oRng
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
Sub insertTOAmacro(ByVal oRng2 As Range)
ActiveDocument.TablesOfAuthorities.MarkCitation _
Range:=Selection.Range, ShortCitation:=Selection.Range.Text, _
LongCitation:=oRng2.Text, Category:=1
End Sub