If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Macro needed: Global table style change
I am trying to create a Word 2000 macro that will look through an entire
document, find all instances of the table style, Simple 1, and change it to table style, Elegant. I can get the following to work in Word 2003: Dim oTable As Table For Each oTable In ActiveDocument.Tables If oTable.Style = "Table Normal" Then oTable.Style = "Table Elegant" oTable.Rows.LeftIndent = InchesToPoints(1) oTable.PreferredWidthType = wdPreferredWidthPoints oTable.PreferredWidth = InchesToPoints(6.5) oTable.Rows(1).Shading.BackgroundPatternColor = wdColorGray15 oTable.Rows(1).HeadingFormat = wdToggle End If Next oTable I have tried to tweak it to no avail for Word 2000. Any help is welcome. -- Jackie Damrau Dynamic Online Training (DOT) |
#2
|
|||
|
|||
Hi Jackie,
The problem is that table styles were first introduced in Word 2002, and don't exist in Word 2000. In VBA for Word 2000, the expression oTable.Style is meaningless and will cause a compile error. You can get the same effect in 2000 by testing for the presence of several of the characteristics of Table Normal -- for example, If (oTable.Borders.OutsideLineStyle = wdLineStyleNone) And (oTable.Borders.InsideLineStyle = wdLineStyleNone) Then and if they match, then apply all the characteristics of Table Elegant plus your additional settings. -- Regards, Jay Freedman http://aspnet2.com/mvp.ashx?JayFreedman Microsoft Word MVP FAQ: http://word.mvps.org "Jackie Damrau" wrote: I am trying to create a Word 2000 macro that will look through an entire document, find all instances of the table style, Simple 1, and change it to table style, Elegant. I can get the following to work in Word 2003: Dim oTable As Table For Each oTable In ActiveDocument.Tables If oTable.Style = "Table Normal" Then oTable.Style = "Table Elegant" oTable.Rows.LeftIndent = InchesToPoints(1) oTable.PreferredWidthType = wdPreferredWidthPoints oTable.PreferredWidth = InchesToPoints(6.5) oTable.Rows(1).Shading.BackgroundPatternColor = wdColorGray15 oTable.Rows(1).HeadingFormat = wdToggle End If Next oTable I have tried to tweak it to no avail for Word 2000. Any help is welcome. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Semicolon delimited text query help | Al Guerra | Running & Setting Up Queries | 3 | August 12th, 2004 11:50 AM |
Macro to extend a pivot table range | Debra Dalgleish | General Discussion | 1 | July 29th, 2004 11:56 AM |
Problems with Style formatting | terrapinie | Formatting Long Documents | 2 | July 7th, 2004 06:18 PM |
use macro to change picture | dgreer | Powerpoint | 5 | June 24th, 2004 07:56 PM |
Writing a macro to change external links to manual updating in Excel 2000 | John Wirt | Links and Linking | 5 | February 16th, 2004 08:03 AM |