Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Sparrahart Sparrahart is offline
external usenet poster
 
Posts: 12
Default Changing size of multiple tables

I have six huge Word 2003 documents with many tables in it that are too wide.
I need to change every one to, say, 18cm wide. Can it be done with a macro
in each doc? I have already changed two documents and it has taken me ages
to select and reduce each table. Again, this will save me precious time and
lots of pain in my right hand.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Henk57[_94_] Henk57[_94_] is offline
external usenet poster
 
Posts: 1
Default Changing size of multiple tables


I dont know about a macro, but if your tables have an assigned style
with defined attributes you can change it there and it should then be a
one time change.
HTH - Henk
Sparrahart;2413878 Wrote:
I have six huge Word 2003 documents with many tables in it that are too
wide.
I need to change every one to, say, 18cm wide. Can it be done with a
macro
in each doc? I have already changed two documents and it has taken me
ages
to select and reduce each table. Again, this will save me precious
time and
lots of pain in my right hand.





--
Henk57
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Changing size of multiple tables

Hi Sparrahart,

The following macro fits all tables in a document to a maximum permitted width of 18cm:

Sub TableResizer()
Application.ScreenUpdating = False
Dim oTableWidth As Single
Dim tTableWidth As Single
Dim oTbl As Table
Dim oCol As Column
' Maximum table width
tTableWidth = CentimetersToPoints(18)
' Exit if there's no tables
If ActiveDocument.Tables.Count = 0 Then Exit Sub
' Test all tables
For Each oTbl In ActiveDocument.Tables
' Calculate the current table's width
oTableWidth = 0
For Each oCol In oTbl.Columns
oTableWidth = oTableWidth + oCol.Width
Next oCol
' Compare against maximum table width
If oTableWidth tTableWidth Then
' Turn off auto sizing & preferred width for oversize tables
With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
End With
' Scale each column's width to fit
For Each oCol In oTbl.Columns
oCol.Width = oCol.Width * tTableWidth / oTableWidth
Next oCol
End If
Next oTbl
Application.ScreenUpdating = True
End Sub

Depending on the amount of text in each cell, you may end up with some of the tables getting longer. To overcome that, you'd
probably need to reduce the font sizes.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Sparrahart" wrote in message ...
I have six huge Word 2003 documents with many tables in it that are too wide.
I need to change every one to, say, 18cm wide. Can it be done with a macro
in each doc? I have already changed two documents and it has taken me ages
to select and reduce each table. Again, this will save me precious time and
lots of pain in my right hand.


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Sparrahart Sparrahart is offline
external usenet poster
 
Posts: 12
Default Changing size of multiple tables

This worked perfectly except I should have mentioned that the table has to be
centred, not default left, on the page. Can you help me out one more time.
I think it is fantastic what you have done. Saved me heaps of time.

Thanks,
Lyn

"macropod" wrote:

Hi Sparrahart,

The following macro fits all tables in a document to a maximum permitted width of 18cm:

Sub TableResizer()
Application.ScreenUpdating = False
Dim oTableWidth As Single
Dim tTableWidth As Single
Dim oTbl As Table
Dim oCol As Column
' Maximum table width
tTableWidth = CentimetersToPoints(18)
' Exit if there's no tables
If ActiveDocument.Tables.Count = 0 Then Exit Sub
' Test all tables
For Each oTbl In ActiveDocument.Tables
' Calculate the current table's width
oTableWidth = 0
For Each oCol In oTbl.Columns
oTableWidth = oTableWidth + oCol.Width
Next oCol
' Compare against maximum table width
If oTableWidth tTableWidth Then
' Turn off auto sizing & preferred width for oversize tables
With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
End With
' Scale each column's width to fit
For Each oCol In oTbl.Columns
oCol.Width = oCol.Width * tTableWidth / oTableWidth
Next oCol
End If
Next oTbl
Application.ScreenUpdating = True
End Sub

Depending on the amount of text in each cell, you may end up with some of the tables getting longer. To overcome that, you'd
probably need to reduce the font sizes.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Sparrahart" wrote in message ...
I have six huge Word 2003 documents with many tables in it that are too wide.
I need to change every one to, say, 18cm wide. Can it be done with a macro
in each doc? I have already changed two documents and it has taken me ages
to select and reduce each table. Again, this will save me precious time and
lots of pain in my right hand.



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Changing size of multiple tables

Hi Sparrahart,

The code I posted doesn't do anything tho change your table alignment - the errant tables must already have been centered. No
matter, this can be fixed in one of two ways:
1. If you want to change the alignment of only the oversized tables, change:

With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
End With

to:

With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
.Rows.Alignment = wdAlignRowLeft
.Rows.LeftIndent = CentimetersToPoints(0)
End With

2. If you want to left-align all tables, change:

End If
Next oTbl

to:

End If
With oTbl.Rows
.Alignment = wdAlignRowLeft
.LeftIndent = CentimetersToPoints(0)
End With
Next oTbl

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Sparrahart" wrote in message ...
This worked perfectly except I should have mentioned that the table has to be
centred, not default left, on the page. Can you help me out one more time.
I think it is fantastic what you have done. Saved me heaps of time.

Thanks,
Lyn

"macropod" wrote:

Hi Sparrahart,

The following macro fits all tables in a document to a maximum permitted width of 18cm:

Sub TableResizer()
Application.ScreenUpdating = False
Dim oTableWidth As Single
Dim tTableWidth As Single
Dim oTbl As Table
Dim oCol As Column
' Maximum table width
tTableWidth = CentimetersToPoints(18)
' Exit if there's no tables
If ActiveDocument.Tables.Count = 0 Then Exit Sub
' Test all tables
For Each oTbl In ActiveDocument.Tables
' Calculate the current table's width
oTableWidth = 0
For Each oCol In oTbl.Columns
oTableWidth = oTableWidth + oCol.Width
Next oCol
' Compare against maximum table width
If oTableWidth tTableWidth Then
' Turn off auto sizing & preferred width for oversize tables
With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
End With
' Scale each column's width to fit
For Each oCol In oTbl.Columns
oCol.Width = oCol.Width * tTableWidth / oTableWidth
Next oCol
End If
Next oTbl
Application.ScreenUpdating = True
End Sub

Depending on the amount of text in each cell, you may end up with some of the tables getting longer. To overcome that, you'd
probably need to reduce the font sizes.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Sparrahart" wrote in message ...
I have six huge Word 2003 documents with many tables in it that are too wide.
I need to change every one to, say, 18cm wide. Can it be done with a macro
in each doc? I have already changed two documents and it has taken me ages
to select and reduce each table. Again, this will save me precious time and
lots of pain in my right hand.






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Sparrahart Sparrahart is offline
external usenet poster
 
Posts: 12
Default Changing size of multiple tables

Dear Macropod,

What a saviour you are! I actually wanted them all centred so just adjusted
your macro to Centre instead of Left and it worked. You are teaching me a
little about macros along the way. One day I just might try and understand
the macro language. I can record them okay (I come from the DOS days -
before Windows) but the lingo in creating them is a bit befuddling.

Thanks once again.

As a PS, this work has been created by someone else and I am having to
reformat it all. Very time consuming.

"macropod" wrote:

Hi Sparrahart,

The code I posted doesn't do anything tho change your table alignment - the errant tables must already have been centered. No
matter, this can be fixed in one of two ways:
1. If you want to change the alignment of only the oversized tables, change:

With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
End With

to:

With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
.Rows.Alignment = wdAlignRowLeft
.Rows.LeftIndent = CentimetersToPoints(0)
End With

2. If you want to left-align all tables, change:

End If
Next oTbl

to:

End If
With oTbl.Rows
.Alignment = wdAlignRowLeft
.LeftIndent = CentimetersToPoints(0)
End With
Next oTbl

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Sparrahart" wrote in message ...
This worked perfectly except I should have mentioned that the table has to be
centred, not default left, on the page. Can you help me out one more time.
I think it is fantastic what you have done. Saved me heaps of time.

Thanks,
Lyn

"macropod" wrote:

Hi Sparrahart,

The following macro fits all tables in a document to a maximum permitted width of 18cm:

Sub TableResizer()
Application.ScreenUpdating = False
Dim oTableWidth As Single
Dim tTableWidth As Single
Dim oTbl As Table
Dim oCol As Column
' Maximum table width
tTableWidth = CentimetersToPoints(18)
' Exit if there's no tables
If ActiveDocument.Tables.Count = 0 Then Exit Sub
' Test all tables
For Each oTbl In ActiveDocument.Tables
' Calculate the current table's width
oTableWidth = 0
For Each oCol In oTbl.Columns
oTableWidth = oTableWidth + oCol.Width
Next oCol
' Compare against maximum table width
If oTableWidth tTableWidth Then
' Turn off auto sizing & preferred width for oversize tables
With oTbl
.AllowAutoFit = False
.PreferredWidth = 0
End With
' Scale each column's width to fit
For Each oCol In oTbl.Columns
oCol.Width = oCol.Width * tTableWidth / oTableWidth
Next oCol
End If
Next oTbl
Application.ScreenUpdating = True
End Sub

Depending on the amount of text in each cell, you may end up with some of the tables getting longer. To overcome that, you'd
probably need to reduce the font sizes.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Sparrahart" wrote in message ...
I have six huge Word 2003 documents with many tables in it that are too wide.
I need to change every one to, say, 18cm wide. Can it be done with a macro
in each doc? I have already changed two documents and it has taken me ages
to select and reduce each table. Again, this will save me precious time and
lots of pain in my right hand.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Font Size/Type in Multiple Word Documents sarahhrrsn Page Layout 2 June 11th 07 08:12 AM
Changing size of Text box Christa Microsoft Word Help 1 June 27th 06 02:25 PM
Tables setting multiple section breaks with multiple headers [email protected] Tables 1 January 19th 06 10:05 AM
Changing format of multiple pre-created tables Wendy Microsoft Word Help 2 September 14th 05 08:55 AM
Changing Column width on Multiple tables.. WordHack Tables 1 May 7th 05 03:24 PM


All times are GMT +1. The time now is 04:27 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"