Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Heading 1 carries over into table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Krakmup - 29 Sep 2005 18:36 GMT
G'Day

I have encountered a unique heading problem.  I generate a table from a
database, move off the table and create a "Heading 1" for my table of
contents, then move back into the table, and format the first line, and
desire to make the first row carry over into new pages.

CODE:
Selection.SelectRow
Selection.ClearFormatting
Selection.Font.Bold = wdToggle
Selection.Font.SmallCaps = wdToggle
Selection.Font.Color = wdColorBlue
Selection.Rows.HeadingFormat = True

The problem, is in Office 2000, and Windows 2000, 98, etc, the second line
is not recognized.  If I delete the second line, then the "Heading 1" carries
over into the table.

Any ideas?
Krakmup
Jean-Guy Marcil - 29 Sep 2005 21:28 GMT
Krakmup was telling us:
Krakmup nous racontait que :

> G'Day
>
[quoted text clipped - 17 lines]
> Any ideas?
> Krakmup

Try not using the selection object... it leads to more complicated and
unstable code.
Without seeing the code you use to create the table, move out of the table,
create the heading and then move back in the table, it is difficult to help.

But, why do you create an object, move out, do something unrelated to the
object, then move back in the object to do something? Why didn't you do
everything before moving out of the object?

Try this code which does not use the Selection object:

Dim MyTable As Table
Dim StartRge As Range
Dim myRow As Row

Set StartRge = Selection.Range
StartRge.Collapse wdCollapseStart

With StartRge
   .InsertAfter "Table Title"
   .Style = wdStyleHeading1
   .InsertParagraphAfter
   .Collapse wdCollapseEnd
   .Style = wdStyleNormal
   .Tables.Add StartRge, 8, 5
   Set myRow = .Tables(1).Rows(1)
   With myRow
       With .Range.Font
           .Bold = True
           .SmallCaps = True
           .Color = wdColorBlue
       End With
       .HeadingFormat = True
   End With
End With

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Klaus Linke - 29 Sep 2005 22:23 GMT
Hi Krakmup,

ClearFormatting seems to do much the same as applying "Normal" style:
Selection.Range.Style = ActiveDocument.Styles(wdStyleNormal)

The only difference I see is that applying "Normal" (built-in command
DemoteToBodyText, with either whole paragraphs or nothing selected) doesn't
remove character styles, "Clear Formatting" does.

So you might apply wdStyleDefaultParagraphFont, too:
Selection.Font.Reset

OTOH, ClearFormatting even removes manual font formatting from the paragraph
if you haven't anything selected (if the paragraph style isn't "Normal", and
more than 50% of the text has manual formatting).

So if you want to mimic "ClearFormatting" 100%, you might have to write more
code. Most of those built-in commands to remove formatting are inordinately
complicated, trying to guess the user's desire.

Regards,
Klaus

> G'Day
>
[quoted text clipped - 18 lines]
> Any ideas?
> Krakmup

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.