Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hello,
While I have a pretty good grasp on recording macros, when it comes to doing something like actual programming, I am in over my head! I have found various code snippets in the groups and have tried to make modifications, but haven't been particularly successful in my quest. Here's what I'm trying to do: I want to modify every table (and only tables) in a document so that the first row is set to a particular style (TableHead), and all remaining rows are set to another particular style (TableText). Okay, that's not completely accurate. I do want to exclude the table on the first page as well as the tables in the headers from this style replacement. The number of tables in the documents I need to modify can range from no tables (other than the one on the first page and in the headers) or up to 60 tables. The number of rows and columns will vary from table to table and document to document. The same holds true for the styles currently being used in the tables. Currently working with Word 2000 for Windows running on Windows 2000. Any advice or help will be greatly appreciated! Dan |
#2
![]() |
|||
|
|||
![]()
The code might look something like this --
Dim pTable as Word.Table Dim pCell as Word.Cell For each pTable in ActiveDocument.Tables If pTable.Range.Information(wdActiveEndPageNumber) 1 then Set pCell = pTable.Cell(1,1) Do If pCell.RowIndex = 1 then pCell.Range.Style = "TableHead" Else pCell.Range.Style = "TableText" End if Set pCell = pCell.Next Loop until pCell is nothing End if Next wrote in message oups.com... Hello, While I have a pretty good grasp on recording macros, when it comes to doing something like actual programming, I am in over my head! I have found various code snippets in the groups and have tried to make modifications, but haven't been particularly successful in my quest. Here's what I'm trying to do: I want to modify every table (and only tables) in a document so that the first row is set to a particular style (TableHead), and all remaining rows are set to another particular style (TableText). Okay, that's not completely accurate. I do want to exclude the table on the first page as well as the tables in the headers from this style replacement. The number of tables in the documents I need to modify can range from no tables (other than the one on the first page and in the headers) or up to 60 tables. The number of rows and columns will vary from table to table and document to document. The same holds true for the styles currently being used in the tables. Currently working with Word 2000 for Windows running on Windows 2000. Any advice or help will be greatly appreciated! Dan |
#3
![]() |
|||
|
|||
![]()
I want to modify every table (and only tables) in a document so that
the first row is set to a particular style (TableHead), and all remaining rows are set to another particular style (TableText). Okay, that's not completely accurate. I do want to exclude the table on the first page as well as the tables in the headers from this style replacement. Hi Dan, Something like Dim i As Long For i = 2 To ActiveDocument.Tables.Count With ActiveDocument.Tables(i) .Range.Style = ActiveDocument.Styles("TableText") .Rows(1).Range.Style = ActiveDocument.Styles("TableHead") End With Next i Greetings, Klaus |
#4
![]() |
|||
|
|||
![]()
That's very neat. It will fail if the table contains any vertically merged
cells, but it may be reasonable to assume that there are none such. "Klaus Linke" wrote in message ... I want to modify every table (and only tables) in a document so that the first row is set to a particular style (TableHead), and all remaining rows are set to another particular style (TableText). Okay, that's not completely accurate. I do want to exclude the table on the first page as well as the tables in the headers from this style replacement. Hi Dan, Something like Dim i As Long For i = 2 To ActiveDocument.Tables.Count With ActiveDocument.Tables(i) .Range.Style = ActiveDocument.Styles("TableText") .Rows(1).Range.Style = ActiveDocument.Styles("TableHead") End With Next i Greetings, Klaus |
#5
![]() |
|||
|
|||
![]()
Jezebel wrote:
That's very neat. Yours too! It will fail if the table contains any vertically merged cells, That... and I assumed (perhaps wrongly) there's only one table on the first page. but it may be reasonable to assume that there are none such. I can only hope so... but now, Dan has your macro as an alternative. And if we both wrongly assumed something else we weren't even aware of, he'll hopefully post back ;-) Greetings, Klaus |
#6
![]() |
|||
|
|||
![]()
Klaus and Jezebel,
I haven't had a chance to try either of your suggestions, but wanted to thank you both. I will give them a try as soon as I get into work! :-) Thank you, thank you, thank you! Dan |
#7
![]() |
|||
|
|||
![]()
Just wanted to let you know that both of your macros have worked for me
in testing with various documents. I can't adequately express how much this has helped me. Thanks again! Dan |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Basic macros query - where are they assigned to? | New Users | |||
How do I create & merge specific data base & master documents? | New Users | |||
word xp crashes after macros are recorded | Microsoft Word Help | |||
WP Delay Code - Word Equiv | Microsoft Word Help | |||
How to change merge forms from Word Perfect to Microsoft Word | Microsoft Word Help |