#1
|
|||
|
|||
Formatting all tables
Hello,
I have about 60 tables in a document I'm working on, I need to apply AutoFit to all of them but I'm having several difficulties. The first problem I found was that I didn't know how to select all the tables at once, I managed to do that using the Visual Basic method and a second possibility is to download KuTools which lets you select the tables by just clicking one button, the results are pretty much the same. Now the problem is that AutoFit is disabled when all the tables are selected, it normally works for one but not for multiple tables. Does anybody have any workaround solution? thanks. |
#2
|
|||
|
|||
Well, I'm replying to myself, just for people having the same problem in the future
Code:
Sub Macro1() ' Dim pT As Word.Table For Each pT In ActiveDocument.Tables pT.PreferredWidth = MillimetersToPoints(170) Next MsgBox "done" End Sub Last edited by macropod; 09-10-2012 at 10:42 PM. Reason: Added code tags & formatting |
#3
|
||||
|
||||
Hi knightmetal,
Your macro doesn't actually apply the autofit attrinbute. Rather, it sets a preferred width which will remain fixed regardless of changes to margins etc. A true autofit macro is more like: Code:
Sub Autofit() Application.ScreenUpdating = False Dim Tbl As Table For Each Tbl In ActiveDocument.Tables Tbl.AutoFitBehavior (wdAutoFitWindow) Tbl.AllowAutoFit = True Next Application.ScreenUpdating = True Application.ScreenRefresh MsgBox "Done", vbOKOnly End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro for selecting pages and formatting of tables | ubns | Word VBA | 25 | 08-15-2012 11:48 PM |
Formatting multiple tables and columns efficiently? | table_column | Word Tables | 1 | 07-02-2012 05:55 PM |
Another Case of Automatic/Zombie Formatting of Tables | MKummerfeldt | Word Tables | 0 | 10-31-2011 10:40 AM |
Copy table cell formatting across multiple cells / tables | pakistanray | Word Tables | 2 | 10-31-2011 08:07 AM |
Whacked formatting in tables (2007) | Roscoe | Word Tables | 6 | 06-11-2010 02:48 PM |