![]() |
|
#1
|
|||
|
|||
|
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
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! |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do you use the find and replace tool to find dates and times in Excel 2013? | Jules90 | Excel | 3 | 04-14-2020 07:40 PM |
| In Find and Replace, can Word stop after each Replace? | wardw | Word | 1 | 06-08-2017 02:47 PM |
Find what box in Find and replace limits the length of a search term
|
Hoxton118 | Word VBA | 7 | 06-10-2014 05:05 AM |
Bad view when using Find and Find & Replace - Word places found string on top line
|
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
Help with find and replace or query and replace
|
shabbaranks | Excel | 4 | 03-19-2011 08:38 AM |