Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-12-2021, 10:26 AM
Javi78503 Javi78503 is offline Find and replace help for a newbie Windows 10 Find and replace help for a newbie Office 2019
Novice
Find and replace help for a newbie
 
Join Date: Jul 2021
Posts: 14
Javi78503 is on a distinguished road
Default Find and replace help for a newbie

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!
Reply With Quote
 



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 and replace help for a newbie Find what box in Find and replace limits the length of a search term Hoxton118 Word VBA 7 06-10-2014 05:05 AM
Find and replace help for a newbie Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Find and replace help for a newbie Help with find and replace or query and replace shabbaranks Excel 4 03-19-2011 08:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft