Re: Paragraph Styles for Text in All Cells by Doug
Doug
Thu Jul 03 20:51:45 CDT 2003
Hi Gerald,
In addition, I had my j's and k's reversed.
Here is a corrected version (once again, the fifth line has wrapped:
Dim i As Integer, j As Integer, k As Integer
For i = 1 To ActiveDocument.Tables.Count
For j = 1 To ActiveDocument.Tables(i).Rows.Count
For k = 1 To ActiveDocument.Tables(i).Columns.Count
ActiveDocument.Tables(i).Cell(j, k).Range.InsertBefore "{" &
ActiveDocument.Tables(i).Cell(j, k).Range.Paragraphs(1).Style & "}"
Next k
Next j
Next i
Please respond to the newsgroups for the benefit of others who may be
interested.
Hope this helps
Doug Robbins - Word MVP
"Doug Robbins - Word MVP" <dkr@mvps.org> wrote in message
news:%23EHGREbQDHA.3664@tk2msftngp13.phx.gbl...
> Hi Gerald,
>
> The email program has wrapped the fifth line of code onto a second line
(the
> sixth). Place the cursor at the end of the fifth line and use the delete
> key to remove the line break.
>
> Please respond to the newsgroups for the benefit of others who may be
> interested.
>
> Hope this helps
> Doug Robbins - Word MVP
> "Gerald Perna" <g.perna@elsevier.com> wrote in message
> news:09ab01c3419a$2eb8fc30$a001280a@phx.gbl...
> > Doug:
> >
> > I get a collection error on the 5th line, and a compile
> > error on the 6th line.
> >
> > Any more help you can give would be appreciated.
> >
> > Thanks.
> >
> > Jerry
> >
> > >-----Original Message-----
> > >Hi Gerald,
> > >
> > >Use
> > >
> > >Dim i As Integer, j As Integer, k As Integer
> > >For i = 1 To ActiveDocument.Tables.Count
> > > For j = 1 To activeDocuemnt.Tables(i).Rows.Count
> > > For k = 1 To ActiveDocument.Tables
> > (i).Columns.Count
> > > ActiveDocument.Tables(i).Cell(k,
> > j).Range.InsertBefore "{" &
> > >ActiveDocument.Tables(i).Cell(k, j).Range.Paragraphs
> > (1).Style & "}"
> > > Next k
> > > Next j
> > >Next i
> > >
> > >Please respond to the newsgroups for the benefit of
> > others who may be
> > >interested.
> > >
> > >Hope this helps
> > >Doug Robbins - Word MVP
> > >"Gerald Perna" <g.perna@elsevier.com> wrote in message
> > >news:05e101c340e6$95d8b950$a101280a@phx.gbl...
> > >> I need to insert the name of the paragraph style in
> > front
> > >> of the text that is in the cells of all the tables in a
> > >> document.
> > >>
> > >> This is how I did it for the regular text in a document:
> > >>
> > >> Dim ParSty As String
> > >> ParSty = Selection.Paragraphs(1).Style
> > >> Selection.Range.InsertBefore "{" & ParSty & "}"
> > >> Do Until Selection.Paragraphs(1).Style = "END"
> > >> Selection.MoveDown Unit:=wdParagraph, Count:=1
> > >> ParSty = Selection.Paragraphs(1).Style
> > >> Selection.Range.InsertBefore "{" & ParSty & "}"
> > >> Loop
> > >>
> > >> It works fine, but I'm not sure how to do the same thing
> > >> for tables. Can anyone help me?
> > >>
> > >> Thanks.
> > >>
> > >> Jerry
> > >
> > >
> > >.
> > >
>
>