Graham i just have one last thing to tweak.
Where the code digits themselves are entered, i have a great
textfield where the values are to be entered
Is there a way i can Find: Code
ld code (inside grey textfield)
Replace with Code:new code (inside grey textfield)
:
In that case
Dim num As String
num = InputBox("Enter the number that is to be inserted.")
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="([Cc]ode)[: 0-9]{1,}",
ReplaceWith:="\1: " & num, _
Forward:=True, MatchWildcards:=True, Wrap:=wdFindStop) = True
Selection.Collapse wdCollapseEnd
Loop
End With
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
DavidRocastle wrote:
I was more looking for something that could offset and delete the
characters to the right Code:
Would you have any ideas? I would like to jus have a single text
box to enter rather than a find and replace.
:
DavidRocastle was telling us:
DavidRocastle nous racontait que :
Thanks for your assistance.
i do have a problem with this piece of code, Jus say i enter it
the first time, i for example enter 1123
i get
Page1:
Code: 1123
Page2:
Code: 1123
.......
and so on.
After i have saved that i want to run it again. and i enter
98701 i get the following
Page1:
Code: 98701 1123
Page2:
Code: 98701 1123
....
and so on
I cannot seem to get rid of the previous data. Would you have
any ideas?
You can modify Doug's original code like this:
Dim numBefore As String
Dim numAfter As String
numBefore = InputBox("Enter the number that is to be replaced.")
numAfter = InputBox("Enter the number that is to be inserted.")
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="Code: " & numAfter,
ReplaceWith:="Code: " & numAfter, _
Forward:=True, Wrap:=wdFindStop) = True
Selection.Collapse wdCollapseEnd
Loop
End With
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org