A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Page Layout
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Find Replace with Section Breaks



 
 
Thread Tools Display Modes
  #1  
Old September 16th, 2004, 04:05 PM
Jason L
external usenet poster
 
Posts: n/a
Default Find Replace with Section Breaks

Hey, I have a somewhat complicated merge request. The user needs a section
break after two words (Recommendations and Discussion - both bolded in TNR,
11 pt) in a document. These words may appear once or several times, but
there needs to be a section break after each one. I was trying to create a
macro, but I'm not sure what the code or character is for section break. I
know the find character is ^b, but that doesn't work for replace.

So, in a nutshell I need a way to find the two words and add a section break
after each one. I thought about a bookmark after each one, and then finding
the bookmark, but that sounds a tad too complicatd for something that seems
so minor.

TIA,
Jason
  #2  
Old September 16th, 2004, 04:36 PM
Jean-Guy Marcil
external usenet poster
 
Posts: n/a
Default

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Hey, I have a somewhat complicated merge request. The user needs a
section
|| break after two words (Recommendations and Discussion - both bolded in
TNR,
|| 11 pt) in a document. These words may appear once or several times, but
|| there needs to be a section break after each one. I was trying to create
a
|| macro, but I'm not sure what the code or character is for section break.
I
|| know the find character is ^b, but that doesn't work for replace.
||
|| So, in a nutshell I need a way to find the two words and add a section
break
|| after each one. I thought about a bookmark after each one, and then
finding
|| the bookmark, but that sounds a tad too complicatd for something that
seems
|| so minor.
||

This should get you started:

'_______________________________________
Const LookFor As String = "Recommendations and Discussion"

With ActiveDocument.Content.Find
.ClearFormatting
.Text = LookFor
With .Font
.Name = "Times New Roman"
.Bold = True
.Size = 11
End With
Do While .Execute
With .Parent
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakContinuous
.Collapse wdCollapseEnd
End With
Loop
End With
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #3  
Old September 16th, 2004, 06:07 PM
Jason L
external usenet poster
 
Posts: n/a
Default

Jean-Guy,

Thanks so much. This works great...sorta. The words are always followed by
a colon. It looks like this:

Recommendations:

1.dsfds
2.sdfdssd
3.dsfds

Discipline:

1.dsfsdfds
2.dsfdsa
3.sdfsdf

When I add colons to the string search, it doesn't find the words. When I
remove the colons, it inserts the section break between the word and the
colon. Any help on this?

TIA,
Jason

"Jean-Guy Marcil" wrote:

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Hey, I have a somewhat complicated merge request. The user needs a
section
|| break after two words (Recommendations and Discussion - both bolded in
TNR,
|| 11 pt) in a document. These words may appear once or several times, but
|| there needs to be a section break after each one. I was trying to create
a
|| macro, but I'm not sure what the code or character is for section break.
I
|| know the find character is ^b, but that doesn't work for replace.
||
|| So, in a nutshell I need a way to find the two words and add a section
break
|| after each one. I thought about a bookmark after each one, and then
finding
|| the bookmark, but that sounds a tad too complicatd for something that
seems
|| so minor.
||

This should get you started:

'_______________________________________
Const LookFor As String = "Recommendations and Discussion"

With ActiveDocument.Content.Find
.ClearFormatting
.Text = LookFor
With .Font
.Name = "Times New Roman"
.Bold = True
.Size = 11
End With
Do While .Execute
With .Parent
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakContinuous
.Collapse wdCollapseEnd
End With
Loop
End With
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org




  #4  
Old September 16th, 2004, 07:01 PM
Jean-Guy Marcil
external usenet poster
 
Posts: n/a
Default

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Jean-Guy,
||
|| Thanks so much. This works great...sorta. The words are always followed
by
|| a colon. It looks like this:
||
|| Recommendations:
||
|| 1.dsfds
|| 2.sdfdssd
|| 3.dsfds
||
|| Discipline:
||
|| 1.dsfsdfds
|| 2.dsfdsa
|| 3.sdfsdf
||
|| When I add colons to the string search, it doesn't find the words. When
I
|| remove the colons, it inserts the section break between the word and the
|| colon. Any help on this?
||

Make sure that your colons are formatted like the words themselves (TNR, 11
pts and Bold)

If they are and it still does not work, post your code so that I can have a
look-see.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #5  
Old September 16th, 2004, 07:01 PM
Jean-Guy Marcil
external usenet poster
 
Posts: n/a
Default

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Jean-Guy,
||
|| Thanks so much. This works great...sorta. The words are always followed
by
|| a colon. It looks like this:
||
|| Recommendations:
||
|| 1.dsfds
|| 2.sdfdssd
|| 3.dsfds
||
|| Discipline:
||
|| 1.dsfsdfds
|| 2.dsfdsa
|| 3.sdfsdf
||
|| When I add colons to the string search, it doesn't find the words. When
I
|| remove the colons, it inserts the section break between the word and the
|| colon. Any help on this?
||

Make sure that your colons are formatted like the words themselves (TNR, 11
pts and Bold)

If they are and it still does not work, post your code so that I can have a
look-see.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #6  
Old September 17th, 2004, 02:45 PM
Jason L
external usenet poster
 
Posts: n/a
Default

Jean-Guy,

Actually, my colon wasn't bolded. Thanks so much for your help. This is
working great now.

-Jason

"Jean-Guy Marcil" wrote:

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Jean-Guy,
||
|| Thanks so much. This works great...sorta. The words are always followed
by
|| a colon. It looks like this:
||
|| Recommendations:
||
|| 1.dsfds
|| 2.sdfdssd
|| 3.dsfds
||
|| Discipline:
||
|| 1.dsfsdfds
|| 2.dsfdsa
|| 3.sdfsdf
||
|| When I add colons to the string search, it doesn't find the words. When
I
|| remove the colons, it inserts the section break between the word and the
|| colon. Any help on this?
||

Make sure that your colons are formatted like the words themselves (TNR, 11
pts and Bold)

If they are and it still does not work, post your code so that I can have a
look-see.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org




  #7  
Old September 17th, 2004, 02:45 PM
Jason L
external usenet poster
 
Posts: n/a
Default

Jean-Guy,

Actually, my colon wasn't bolded. Thanks so much for your help. This is
working great now.

-Jason

"Jean-Guy Marcil" wrote:

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Jean-Guy,
||
|| Thanks so much. This works great...sorta. The words are always followed
by
|| a colon. It looks like this:
||
|| Recommendations:
||
|| 1.dsfds
|| 2.sdfdssd
|| 3.dsfds
||
|| Discipline:
||
|| 1.dsfsdfds
|| 2.dsfdsa
|| 3.sdfsdf
||
|| When I add colons to the string search, it doesn't find the words. When
I
|| remove the colons, it inserts the section break between the word and the
|| colon. Any help on this?
||

Make sure that your colons are formatted like the words themselves (TNR, 11
pts and Bold)

If they are and it still does not work, post your code so that I can have a
look-see.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org




  #8  
Old September 17th, 2004, 02:56 PM
Jean-Guy Marcil
external usenet poster
 
Posts: n/a
Default

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Jean-Guy,
||
|| Actually, my colon wasn't bolded. Thanks so much for your help. This is
|| working great now.
||

Glad you sorted it out.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #9  
Old September 17th, 2004, 02:56 PM
Jean-Guy Marcil
external usenet poster
 
Posts: n/a
Default

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Jean-Guy,
||
|| Actually, my colon wasn't bolded. Thanks so much for your help. This is
|| working great now.
||

Glad you sorted it out.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #10  
Old September 17th, 2004, 07:39 PM
Jason L
external usenet poster
 
Posts: n/a
Default

Jean-Guy,

I guess I spoke too soon. When the section break is entered, a large space
is created beneath the word and the next paragraph or sentence. This is not
a huge deal, but the user is unhappy with it.

Here is the code I am using for the section break:

Const LookFor As String = "Recommendations:"

With ActiveDocument.Content.Find
.ClearFormatting
.Text = LookFor
With .Font
.Name = "Times New Roman"
.Bold = True
.Size = 11
End With
Do While .Execute
With .Parent
.Collapse wdCollapseEnd
.InsertBreak wdSectionBreakContinuous
.Collapse wdCollapseEnd


End With
Loop
End With

I tried to use something like this to remove the space (which has the
paragraph marker tied to the section break in this area), but it's not
working. Essentially, it looks like this:

RecommendationsSection break)
Paragraph Mark tied to section break

(New Text )

Thanks for any help you can give.

-Jason


"Jean-Guy Marcil" wrote:

Bonjour,

Dans son message, Jason L écrivait :
In this message, Jason L wrote:

|| Jean-Guy,
||
|| Actually, my colon wasn't bolded. Thanks so much for your help. This is
|| working great now.
||

Glad you sorted it out.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace Nelson Ferry General Discussion 2 August 17th, 2004 04:09 PM
find and replace ladyinred General Discussion 14 August 12th, 2004 09:35 PM
Advanced find and replace - Word XP Melissa General Discussions 4 May 10th, 2004 02:45 PM
find all / replace all used in a selected range oldguy Worksheet Functions 0 February 26th, 2004 02:05 PM
find all / replace all used in a selected range Tom Turtle Worksheet Functions 0 February 26th, 2004 11:11 AM


All times are GMT +1. The time now is 09:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.