Jean-Guy
Thu Sep 29 15:28:20 CDT 2005
Krakmup was telling us:
Krakmup nous racontait que :
> 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
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
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site:
http://www.word.mvps.org