Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 02-27-2023, 06:36 AM
RaymondB7777 RaymondB7777 is offline Find and Prompt the user to Replace Windows 10 Find and Prompt the user to Replace Office 2021
Novice
 
Join Date: Feb 2023
Posts: 2
RaymondB7777 is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
Gents,

Just tinkering here. Maybe I am missings something, but I don't see a need for .Duplicate in this case.


HTML Code:
Sub PromptReplace()
Dim oRngStart As Word.Range
Dim oRng As Range, lngIndex As Long
Dim arrFnd() As String, arrRpl() As String
Set oRngStart = Selection.Range
'find terms
arrFnd = Split("tot;tow;trail;contact;delivery;fist;form;latter;diffused;" _
& "singed;sing;asset;tortuous;emotion;owning;statue;conversion", ";")
'replace terms
arrRpl = Split("to;twos;trial;contract;deliver;first;from;later;defused;" _
& "signed;sign;assert;tortious;motion;owing;statute;conversation", ";")
 
For lngIndex = 0 To UBound(arrFnd)
For Each oRng In ActiveDocument.StoryRanges
With oRng.Find
.ClearFormatting
.Text = arrFnd(lngIndex)
.Forward = True
.Wrap = wdFindStop
While .Execute
Application.ScreenRefresh
oRng.Select
Select Case MsgBox("Replace " & Chr(34) & arrFnd(lngIndex) & Chr(34) & " with " & Chr(34) & arrRpl(lngIndex) & Chr(34) & "?", _
vbYesNoCancel + vbDefaultButton1, "Replace")
Case vbYes
oRng.Text = arrRpl(lngIndex)
Case vbCancel
GoTo lbl_Exit
End Select
oRng.Collapse wdCollapseEnd
Wend
End With
Next oRng
Next lngIndex
lbl_Exit:
oRngStart.Select
Set oRng = Nothing: Set oRngStart = Nothing
End Sub
Hi Graham, I have modified your VBA to cater for my own specific requirements and it works well.

However, how would I go about restricting this to selected test only?

I have a number of tables with 2 columns.

Column 1 contains the original text (which does not necessarily contain the relevant Capitalized words)

Column 2 contains the text I have modified and added to and may or may not contain the the relevant Capitalized words. This is the column that I want to search/replace.

i.e. Column must 1 must not be searched/replaced.

Thanks in advance

Raymond
Reply With Quote
 

Tags
code



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Prompt the user to Replace Find, Replace Ajay Shahane Word VBA 4 05-16-2012 04:07 AM
Find and Prompt the user to Replace 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 Prompt the user to Replace Is there a way to use "find/replace" to find italics words? slayda Word 3 09-14-2011 02:16 PM
Find and Prompt the user to Replace Help with find and replace or query and replace shabbaranks Excel 4 03-19-2011 08:38 AM
User Name Prompt Appears When Opening Documents galleherjazz Office 0 07-30-2009 08:15 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:48 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