View Single Post
  #3  
Old August 12th, 2006, 11:57 PM posted to microsoft.public.word.pagelayout
MarkLTaper
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