Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2017, 10:10 PM
Bazzao Bazzao is offline Separate Find Replace Windows 10 Separate Find Replace Office 2003
Novice
Separate Find Replace
 
Join Date: Apr 2017
Posts: 3
Bazzao is on a distinguished road
Post Separate Find Replace

I need to separate the find / replace in Word VBA.

The code would follow this structure:

set find and replace text

for each matching find
__ if it matches conditions [specifically within a range] then
____ perform replace on current find
next

Thanks


bazzao
Reply With Quote
  #2  
Old 04-20-2017, 10:58 PM
macropod's Avatar
macropod macropod is offline Separate Find Replace Windows 7 64bit Separate Find Replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You will need to provide more information about what the conditions are.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-23-2017, 05:13 PM
Bazzao Bazzao is offline Separate Find Replace Windows 10 Separate Find Replace Office 2003
Novice
Separate Find Replace
 
Join Date: Apr 2017
Posts: 3
Bazzao is on a distinguished road
Default

Basically the conditions are the finds are within a range of the document.

The range has been found by another process.

So if the find is > LowerLimit and < UpperLimit then replace. LowerLimit and UpperLimit are long integer variables.

After posting the question, a solution came to me. But I don't know how to code it.

The code would be:

* Select from LowerLimit to UpperLimit.
* Search (multiple searches) and replace within that range.

As there are multiple find/replaces, the selection would have to remain intact.

An issue would be where the replacement text is not of the same length as the find text.
Reply With Quote
  #4  
Old 04-23-2017, 05:31 PM
macropod's Avatar
macropod macropod is offline Separate Find Replace Windows 7 64bit Separate Find Replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Again, it is by no means apparent what 'LowerLimit' and 'UpperLimit' relate to. Are these numbers that appear in the document, range addresses, something else?

Your descriptions so far are best described as obscure. Clarity is needed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-24-2017, 01:27 AM
Bazzao Bazzao is offline Separate Find Replace Windows 10 Separate Find Replace Office 2003
Novice
Separate Find Replace
 
Join Date: Apr 2017
Posts: 3
Bazzao is on a distinguished road
Default

LowerLimit is the lower limit of the replacement range. UpperLimit is the upper limit of the replacement range. These are variables set by another process which is working.

So how do I:
1) set a selection to between lower & upper limits
2) find & replace within that selection
3) modify UpperLimit where the replacement text is not the same length as the find text.

Note: there are multiple separate find/replaces for the needed application, so in 2 above there are multiple "replaceall"s.
Reply With Quote
  #6  
Old 04-24-2017, 04:17 AM
macropod's Avatar
macropod macropod is offline Separate Find Replace Windows 7 64bit Separate Find Replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Clear as mud.

If you're referring to range offsets within the document (e.g. With ActiveDocument.Range(Start:=50, End:=150).Find, where LowerLimit = 50 & UpperLimit = 150), this all becomes problematic once you start working with ranges that span fields, tables, etc.; even more so when the Find/Replace strings don't have the same lengths - the first such Find/Replace immediately invalidates the offsets for any Find/Replace that works with content deeper in the document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
conditional find replace, find, replace

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Separate Find Replace VBA Batch Find & Replace for all MSOffice extensions, to replace File Name and Content of the File QA_Compliance_Advisor Word VBA 11 09-11-2014 11:51 PM
Separate Find Replace 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/Find and Replace Loop Tango Mike Word 3 04-20-2014 02:47 PM
Separate Find 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
Separate Find Replace 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 01:56 AM.


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