Hello all again,
With time, you can do anything. If you want the solution
to this, this is what I found:
This macro would run, from an point before the document
is for example printed. Or could be behind a toolbar
button.
Identify where the reference field starts and pass in the
details. I am assuming the refernce field is on its own
line. If not you would need the MoveEndUntil function
...
strOurRef = TrapTheReference("Our ref:")
If strOurRef = "" Then
strOurRef = TrapTheReference("Our reference:")
End If
.
Function TrapTheReference(strSearchText As String) As
String
Dim strSelectedText As String
With Selection
.Find.ClearFormatting
With .Find
.Text = strSearchText
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
End With
.Find.Execute
.MoveRight Unit:=wdCharacter, Count:=2
.EndKey Unit:=wdLine, Extend:=wdExtend
.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
End With
strSelectedText = Selection.Text
Selection.MoveRight Unit:=wdCharacter, Count:=1
TrapTheReference = strSelectedText
End Function
It seems to do the trick. Hope you find it useful and
something to build on. Don't forget any error handling
you may need.
Cheers
John J.
>-----Original Message-----
>Hello all,
[quoted text clipped - 25 lines]
>John J
>.