A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macro needed: Global table style change



 
 
Thread Tools Display Modes
  #1  
Old August 24th, 2004, 11:05 PM
Jackie Damrau
external usenet poster
 
Posts: n/a
Default 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  
Old August 25th, 2004, 03:02 AM
Jay Freedman
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 03:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.