Hey guys, quick rundown of what i'm trying to accomplish. I've created a form that updates bookmarks (maybe not the best way but it gets the job done so far) What I'm trying to make is a field that updates as you type it in. I can get it to do that easy enough, but my struggle is trying to get it to replace the old text with new text if you change the textbox value. this is what I have so far and I can't seem to figure out how to find and delete the old text..or replace it..
Code:
Private Sub PNBox_AfterUpdate()
If oldPN <> "" Then
With ActiveDocument.Content.Find
.Text = oldPN
.Replacement.ClearFormatting
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll, Forward:=True, _
Wrap:=wdFindContinue
End With
End If
ActiveDocument.Bookmarks("bmPN").Select
Selection.Text = StrConv(Me.PNBox.Value, vbProperCase)
oldPN = Me.PNBox.Value
End Sub
I set oldPN as a string at the top of the page and am trying to:
1. check if oldPN is still null
2. if not, find and delete all instances of oldPN in the form (should be at bookmarks)
3. update bookmarks with new textbox value
4. update oldPN to be the newly entered value so it can have something to compare if it changes again.
currently i'm just getting the new value added in front of the old value into an ever growing string.
Thanks in advance for any help!