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 / March 2006

Tip: Looking for answers? Try searching our database.

Table formatting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KC8DCN - 27 Mar 2006 03:44 GMT
I have a document that has about 60 tables in it.  

I'm working on a macro that will insert a row the second row, copy the
formatting in row 2 column 1 and apply that to the rest of the cells in that
column, copy the formatting in row 2 cell 2 and apply that to the rest of the
cells in that column, etc., and then delete the extra row that was inserted
to copy the formatting from.

The formatting in the extra row contains a specific font size, style and a
decimal tab.  

I have, however, been unsuccessful in finding how to copy the formatting of
one cell and apply it to another.  Is this possible?

Thanks!  
Jezebel - 27 Mar 2006 07:23 GMT
The trick is that cells don't have formatting: that belongs to the range
within the cell, eg

   Dim pTable as Word.Table
   Dim pR1 As Word.Range
   Dim pR2 As Word.Range
   Dim pColumn as long
   Dim pRow As Long

   Set pTable = Selection.Tables(1)

   For pColumn = 1 to pTable.Columns.Count
       Set pR1 = pTable.Cell(2, pColumn).Range

       for pRow = 3 to pTable.Rows.Count
           Set pR2 = pTable.Cell(pRow, pColumn).Range

           With pR1.Font
               pR2.Font.Bold = .Bold
               pR2.Font.Color = .Color
               pR2.Font.Size = .Size
               :    [there are lots of properties you might want to set...]
           End With
       Next
Next

But what's the point of inserting the row? -- The row you insert will
inherit the format from the row above, so why not use that?

>I have a document that has about 60 tables in it.
>
[quoted text clipped - 15 lines]
>
> Thanks!
KC8DCN - 28 Mar 2006 00:11 GMT
The first row has the column headings in it; the second, has the formatting
that I would like for the rest of the column.  By inserting a row above the
second row, I can insert the information that I want, grab the formatting in
the second row and copy that to the rest of the column.  

I'll try that.  Thanks!

> The trick is that cells don't have formatting: that belongs to the range
> within the cell, eg
[quoted text clipped - 44 lines]
> >
> > Thanks!
 
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.