atw: Re: Word macro - set table width

Close! You screwed up identifying the tables, use this instead. Also note
the explicit destruction of the object.

Sub Fixed_width_Tables()
    Dim aTable As Table
    For Each aTable In ActiveDocument.Tables
        With aTable
            .PreferredWidthType = wdPreferredWidthPoints
            .PreferredWidth = CentimetersToPoints(13)
        End With
    Next
    Set aTable = Nothing
End Sub

 

-----Original Message-----
From: Ilana Cohney


Hi all,
Would any of you happen to know how to write a macro that runs through a
document and sets all tables to a set width.  I generate my Word XP
documents via AuthorIT and the tables come out all different widths which
looks terrible.  I have tried writing a macro but my macro skills are still
in the very beginnning stages.  So far my macro looks like this:
Sub Fixed_width_Tables()
    Dim myObject As Table
    For Each myObject In ActiveDocument.Tables
        With Selection.Tables(1)
            .PreferredWidthType = wdPreferredWidthPoints
            .PreferredWidth = CentimetersToPoints(13)
        End With
    Next
End Sub

My problem is that it works for one table and then stops!  Any idea how to
tell it to continue on through the document and resize all tables.
Thanks for your help.
Ilana
**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with
"unsubscribe" in the Subject field.

To search the austechwriter archives, go to
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************


**************************************************
To post a message to austechwriter, send the message to 
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to 
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with 
"unsubscribe" in the Subject field.

To search the austechwriter archives, go to 
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to 
austechwriter-admins@xxxxxxxxxxxxx
**************************************************

Other related posts: