Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.pagelayout
MarkLTaper MarkLTaper is offline
external usenet poster
 
Posts: 5
Default How to create style to automatically suppress CR after a Heading?

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text

  #2   Report Post  
Posted to microsoft.public.word.pagelayout
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How to create style to automatically suppress CR after a Heading?

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text

  #3   Report Post  
Posted to microsoft.public.word.pagelayout
MarkLTaper MarkLTaper is offline
external usenet poster
 
Posts: 5
Default How to create style to automatically suppress CR after a Headi

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text


  #4   Report Post  
Posted to microsoft.public.word.pagelayout
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How to create style to automatically suppress CR after a Headi

Hi Mark,

Ask and ye shall receive....

Sub RuninAllHeading4()
Dim SearchRg As Range
Dim HideRg As Range
Set SearchRg = ActiveDocument.Range
With SearchRg.Find
.ClearFormatting
.Text = ""
.Style = wdStyleHeading4
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
Set HideRg = SearchRg.Duplicate
With HideRg
.Collapse wdCollapseEnd
.MoveStartWhile cset:=Chr(13), Count:=wdBackward
.Font.Hidden = True
End With

With SearchRg
.Collapse wdCollapseEnd
.MoveEnd unit:=wdCharacter, Count:=1
.Select
If (.Text " ") And (.Text Chr$(9)) Then
.InsertBefore " "
End If
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 15:57:01 -0700, MarkLTaper
wrote:

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text


  #5   Report Post  
Posted to microsoft.public.word.pagelayout
MarkLTaper MarkLTaper is offline
external usenet poster
 
Posts: 5
Default How to create style to automatically suppress CR after a Headi

Well I didn't want to ask because that would have been greedy. This is
perfect, and I doubt I could have constructed it myself.

Thanks MarkLTaper

"Jay Freedman" wrote:

Hi Mark,

Ask and ye shall receive....

Sub RuninAllHeading4()
Dim SearchRg As Range
Dim HideRg As Range
Set SearchRg = ActiveDocument.Range
With SearchRg.Find
.ClearFormatting
.Text = ""
.Style = wdStyleHeading4
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
Set HideRg = SearchRg.Duplicate
With HideRg
.Collapse wdCollapseEnd
.MoveStartWhile cset:=Chr(13), Count:=wdBackward
.Font.Hidden = True
End With

With SearchRg
.Collapse wdCollapseEnd
.MoveEnd unit:=wdCharacter, Count:=1
.Select
If (.Text " ") And (.Text Chr$(9)) Then
.InsertBefore " "
End If
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 15:57:01 -0700, MarkLTaper
wrote:

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text




  #6   Report Post  
Posted to microsoft.public.word.pagelayout
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How to create style to automatically suppress CR after a Headi

You're welcome.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 17:18:01 -0700, MarkLTaper
wrote:

Well I didn't want to ask because that would have been greedy. This is
perfect, and I doubt I could have constructed it myself.

Thanks MarkLTaper

"Jay Freedman" wrote:

Hi Mark,

Ask and ye shall receive....

Sub RuninAllHeading4()
Dim SearchRg As Range
Dim HideRg As Range
Set SearchRg = ActiveDocument.Range
With SearchRg.Find
.ClearFormatting
.Text = ""
.Style = wdStyleHeading4
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
Set HideRg = SearchRg.Duplicate
With HideRg
.Collapse wdCollapseEnd
.MoveStartWhile cset:=Chr(13), Count:=wdBackward
.Font.Hidden = True
End With

With SearchRg
.Collapse wdCollapseEnd
.MoveEnd unit:=wdCharacter, Count:=1
.Select
If (.Text " ") And (.Text Chr$(9)) Then
.InsertBefore " "
End If
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 15:57:01 -0700, MarkLTaper
wrote:

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text


  #7   Report Post  
Posted to microsoft.public.word.pagelayout
Dan Hart Dan Hart is offline
external usenet poster
 
Posts: 2
Default How to create style to automatically suppress CR after a Headi

Is a macro still the only option for creating a heading with no CR/LF? Any
updates on this answer?

"Jay Freedman" wrote:

You're welcome.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 17:18:01 -0700, MarkLTaper
wrote:

Well I didn't want to ask because that would have been greedy. This is
perfect, and I doubt I could have constructed it myself.

Thanks MarkLTaper

"Jay Freedman" wrote:

Hi Mark,

Ask and ye shall receive....

Sub RuninAllHeading4()
Dim SearchRg As Range
Dim HideRg As Range
Set SearchRg = ActiveDocument.Range
With SearchRg.Find
.ClearFormatting
.Text = ""
.Style = wdStyleHeading4
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
Set HideRg = SearchRg.Duplicate
With HideRg
.Collapse wdCollapseEnd
.MoveStartWhile cset:=Chr(13), Count:=wdBackward
.Font.Hidden = True
End With

With SearchRg
.Collapse wdCollapseEnd
.MoveEnd unit:=wdCharacter, Count:=1
.Select
If (.Text " ") And (.Text Chr$(9)) Then
.InsertBefore " "
End If
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 15:57:01 -0700, MarkLTaper
wrote:

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text



  #8   Report Post  
Posted to microsoft.public.word.pagelayout
Dan Hart Dan Hart is offline
external usenet poster
 
Posts: 2
Default How to create style to automatically suppress CR after a Headi

Is a macro still the only option for creating a heading with no CR/LF? Any
updates on this answer?

"Jay Freedman" wrote:

You're welcome.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 17:18:01 -0700, MarkLTaper
wrote:

Well I didn't want to ask because that would have been greedy. This is
perfect, and I doubt I could have constructed it myself.

Thanks MarkLTaper

"Jay Freedman" wrote:

Hi Mark,

Ask and ye shall receive....

Sub RuninAllHeading4()
Dim SearchRg As Range
Dim HideRg As Range
Set SearchRg = ActiveDocument.Range
With SearchRg.Find
.ClearFormatting
.Text = ""
.Style = wdStyleHeading4
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
Set HideRg = SearchRg.Duplicate
With HideRg
.Collapse wdCollapseEnd
.MoveStartWhile cset:=Chr(13), Count:=wdBackward
.Font.Hidden = True
End With

With SearchRg
.Collapse wdCollapseEnd
.MoveEnd unit:=wdCharacter, Count:=1
.Select
If (.Text " ") And (.Text Chr$(9)) Then
.InsertBefore " "
End If
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 15:57:01 -0700, MarkLTaper
wrote:

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text



  #9   Report Post  
Posted to microsoft.public.word.pagelayout
DeanH DeanH is offline
external usenet poster
 
Posts: 1,862
Default How to create style to automatically suppress CR after a Headi

There is no way of creating a Heading with out a paragraph mark because these
are by definition a paragraph style BUT you can by using the Style Separator
to combine the Heading and the following text. And only the "Heading" text
will show in the Table of Contents if that is something that you require.

Alt+Ctrl+Return or InsertStyleSeparator icon in the Commands listing.

Hope this helps
DeanH


"Dan Hart" wrote:

Is a macro still the only option for creating a heading with no CR/LF? Any
updates on this answer?

"Jay Freedman" wrote:

You're welcome.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 17:18:01 -0700, MarkLTaper
wrote:

Well I didn't want to ask because that would have been greedy. This is
perfect, and I doubt I could have constructed it myself.

Thanks MarkLTaper

"Jay Freedman" wrote:

Hi Mark,

Ask and ye shall receive....

Sub RuninAllHeading4()
Dim SearchRg As Range
Dim HideRg As Range
Set SearchRg = ActiveDocument.Range
With SearchRg.Find
.ClearFormatting
.Text = ""
.Style = wdStyleHeading4
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
Set HideRg = SearchRg.Duplicate
With HideRg
.Collapse wdCollapseEnd
.MoveStartWhile cset:=Chr(13), Count:=wdBackward
.Font.Hidden = True
End With

With SearchRg
.Collapse wdCollapseEnd
.MoveEnd unit:=wdCharacter, Count:=1
.Select
If (.Text " ") And (.Text Chr$(9)) Then
.InsertBefore " "
End If
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 15:57:01 -0700, MarkLTaper
wrote:

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text



  #10   Report Post  
Posted to microsoft.public.word.pagelayout
DeanH DeanH is offline
external usenet poster
 
Posts: 1,862
Default How to create style to automatically suppress CR after a Headi

There is no way of creating a Heading with out a paragraph mark because these
are by definition a paragraph style BUT you can by using the Style Separator
to combine the Heading and the following text. And only the "Heading" text
will show in the Table of Contents if that is something that you require.

Alt+Ctrl+Return or InsertStyleSeparator icon in the Commands listing.

Hope this helps
DeanH


"Dan Hart" wrote:

Is a macro still the only option for creating a heading with no CR/LF? Any
updates on this answer?

"Jay Freedman" wrote:

You're welcome.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 17:18:01 -0700, MarkLTaper
wrote:

Well I didn't want to ask because that would have been greedy. This is
perfect, and I doubt I could have constructed it myself.

Thanks MarkLTaper

"Jay Freedman" wrote:

Hi Mark,

Ask and ye shall receive....

Sub RuninAllHeading4()
Dim SearchRg As Range
Dim HideRg As Range
Set SearchRg = ActiveDocument.Range
With SearchRg.Find
.ClearFormatting
.Text = ""
.Style = wdStyleHeading4
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
Do While .Execute
Set HideRg = SearchRg.Duplicate
With HideRg
.Collapse wdCollapseEnd
.MoveStartWhile cset:=Chr(13), Count:=wdBackward
.Font.Hidden = True
End With

With SearchRg
.Collapse wdCollapseEnd
.MoveEnd unit:=wdCharacter, Count:=1
.Select
If (.Text " ") And (.Text Chr$(9)) Then
.InsertBefore " "
End If
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 15:57:01 -0700, MarkLTaper
wrote:

Jay, This is great. I can see that macros open up a vast flexibility. I
will work on implimenting this macro. However, I am thinking that for my
purposes, a macro that searchs for every level 4 heading goes to its end and
hides the CR would be most effective. Are their subtle enough search
functions in the macro language to make this approach work? If you think so
then I will try to work this out.

Thanks again

"Jay Freedman" wrote:

OK, I see what you're trying to do. It will be possible with a macro
-- more likely, a series of macros -- that do all the formatting. You
can assign each macro to a toolbar button, a shortcut key, or both.

An example macro is shown below. This is specific for the situation
you showed; if you want other heading styles, or other assumptions
about the starting selection, you'd need other macros for those.

This example assumes that you've already typed the text of both the
heading and at least part of the following text, all in the regular
body style in a single paragraph, and that you've selected the part
you want to make into a Heading 4. It doesn't work right if you select
an entire paragraph.

Sub ApplyRunin4()
' the selected text will take Heading 4 style
' with a hidden paragraph mark at the end

If Selection.Type wdSelectionNormal Then
MsgBox "Please select the heading text first."
Exit Sub
End If

If Selection.Start Selection.Paragraphs(1).Range.Start Then
MsgBox "Please select text at the beginning of the paragraph."
Exit Sub
End If

With Selection
.InsertParagraphAfter
.Collapse wdCollapseStart
.Style = ActiveDocument.Styles("Heading 4")
.Paragraphs(1).Range.Select
.Collapse wdCollapseEnd
.MoveStart wdCharacter, -1
.Font.Hidden = True
End With
End Sub

For help with installing the macro and assigning it to a button and/or
shortcut, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Custom...oToToolbar.htm
http://www.word.mvps.org/FAQs/Custom...roToHotkey.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 12 Aug 2006 12:03:02 -0700, MarkLTaper
wrote:

I am trying to create a heading style so that following text begins on the
same line, but I am baffled. I see no way to suppress the carriage return.
Jay Freedman's response to my previous question showed how to manually
format to create the proper effect on a case by case basis not how to set up
a style.
I use this format frequently so I would like to have it automatic, if
possible.

Thanks MLT

I want:

Heading 4: Following text

not

Heading 4:
Following text



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlinks within document go to wrong place Laura79 Microsoft Word Help 7 April 27th 06 04:21 PM
Multiple Tables of Contents problem Cheryl Cavanaugh Microsoft Word Help 2 February 10th 06 01:38 PM
Heading 1 style overriding TOC 1 style Jennifer_Lee Page Layout 4 October 28th 05 05:43 PM
How to customize Headers? Saviourmachine Page Layout 6 August 4th 05 11:04 PM
My custom styles are acquiring unwanted attributes Frustrated Frame User Microsoft Word Help 10 April 21st 05 09:38 AM


All times are GMT +1. The time now is 09:57 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"