Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2014, 02:47 PM
JFDI JFDI is offline Find/Replace adds a style to what I'm searching for AND the following paragraph Windows 7 64bit Find/Replace adds a style to what I'm searching for AND the following paragraph Office 2007
Novice
Find/Replace adds a style to what I'm searching for AND the following paragraph
 
Join Date: Mar 2014
Posts: 2
JFDI is on a distinguished road
Red face Find/Replace adds a style to what I'm searching for AND the following paragraph

I am using the (wildcards enabled) regular expression ([0-9]{1,})^p to find chapter headings (which are just numbers followed by a carriage return) and replace them with ^m\1^p^p^p and the style Heading 1. The result I am getting is that Heading 1 is improperly applied (I modified Heading 1 to centered, but it is justified in the instances where find/replace makes the changes but centered elsewhere) but also bleeds into the next paragraph. I end up with the page break, and the mis-styled chapter heading, the three returns AND the entire next paragraph styled as Heading 1.



I guess maybe the reason the chapter heading is justified is because it is picking that attribute up from the following paragraph? But how can I keep find/replace from trying to incorporate the two?

Thanks in advance. Sorry if it's already been asked or it's dumb but I'm new to regex and the results I am getting are hard to search for.

I'm using Microsoft Word 2007 on win7-64 in case that's relevant.
Reply With Quote
  #2  
Old 03-27-2014, 04:34 PM
macropod's Avatar
macropod macropod is offline Find/Replace adds a style to what I'm searching for AND the following paragraph Windows 7 32bit Find/Replace adds a style to what I'm searching for AND the following paragraph Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

The F/R is behaving that way because you've specified a Style name for the Find/Replace. Anything replaced that way adopts the same Style. The use of wildcards has nothing to do with that one way or the other. In any event, instead of inserting two extra paragraph breaks after the Heading, what you should do is change the Heading 1 Style's definition so that it includes an appropriate 'space after' value (e.g. 24pt). If you want to avoid the page breaks adopting the Heading 1 Style, do the Find/Replace in two steps: first insert the page breaks; then apply the Style, viz.:
Find = [0-9]{1,}^13
Replace = ^m^&
Replace = ^&
with the second one specifying Heading 1 for the Style.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-27-2014, 05:36 PM
JFDI JFDI is offline Find/Replace adds a style to what I'm searching for AND the following paragraph Windows 7 64bit Find/Replace adds a style to what I'm searching for AND the following paragraph Office 2007
Novice
Find/Replace adds a style to what I'm searching for AND the following paragraph
 
Join Date: Mar 2014
Posts: 2
JFDI is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The F/R is behaving that way because you've specified a Style name for the Find/Replace. Anything replaced that way adopts the same Style. The use of wildcards has nothing to do with that one way or the other. In any event, instead of inserting two extra paragraph breaks after the Heading, what you should do is change the Heading 1 Style's definition so that it includes an appropriate 'space after' value (e.g. 24pt). If you want to avoid the page breaks adopting the Heading 1 Style, do the Find/Replace in two steps: first insert the page breaks; then apply the Style, viz.:
Find = [0-9]{1,}^13
Replace = ^m^&
Replace = ^&
with the second one specifying Heading 1 for the Style.

Alright, thanks for the tip. After I had to frame the question to post that it occurred to me that it might be best done in two steps and you seem to confirm that. I will try your suggestion of modifying the Style next time this comes up.

Cheers
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use find and replace to change text to a custom style wrdy Word 7 03-11-2014 12:09 AM
Find/Replace adds a style to what I'm searching for AND the following paragraph 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 bullets and replace with paragraph style? cdybdahl Word 1 12-02-2011 02:14 AM
Find and replace multiple documents change style BaPW Word 0 08-14-2011 11:12 AM
Character style stripped while applying paragraph style sams_gates Word 0 08-29-2009 02:03 AM

Other Forums: Access Forums

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