Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2011, 12:48 AM
boutells boutells is offline Auto fit tables to page Windows Vista Auto fit tables to page Office 2007
Novice
Auto fit tables to page
 
Join Date: May 2009
Posts: 24
boutells is on a distinguished road
Default Auto fit tables to page

I have just spent about half an hour to create a Word Template that was a 4 cell table which I wanted to fit to an A4 page. About 10 minutes of this was trying to find an easy solution in the help files which provided no joy.



There must be a way to insert a table on a page defining the number of rows and columns and have it autofit the page where it is being inserted.

Any solutions?
Reply With Quote
  #2  
Old 07-20-2011, 01:12 AM
macropod's Avatar
macropod macropod is offline Auto fit tables to page Windows 7 64bit Auto fit tables to page Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi boutells,

Nothing built-in, though the default width fits the page margins (plus whatever internal cell margins the table has). However, you could insert the table, then format its height with a macro. The following macro fits all selected tables to the height of the page in the section in which they appear. Whether the tables actually print that way depends on whether there is anything else on the same pages:
Code:
Sub TableFit()
Application.ScreenUpdating = False
Dim oTopMargin As Single, oBottomMargin As Single, oBottomLine As Single
Dim oPageHeight As Single, oPrintHeight As Single, oRowHeight As Single
Dim oTable, oCell As Cell, i As Integer
If Selection.Tables.Count = 0 Then Exit Sub
For i = 1 To Selection.Tables.Count
  oTable = Selection.Tables(i)
  oBottomLine = 0
  With oTable
    For Each oCell In oTable.Rows(oTable.Rows.Count).Cells
      If .Borders(wdBorderBottom).LineWidth > oBottomLine Then _
        oBottomLine = .Borders(wdBorderBottom).LineWidth
    Next
    With .PageSetup
      oTopMargin = .TopMargin
      oBottomMargin = .BottomMargin
      oPageHeight = .PageHeight
    End With
    oPrintHeight = oPageHeight - oTopMargin - oBottomMargin - oBottomLine / 8 - 1
    oRowHeight = oPrintHeight / .Rows.Count
    With .Rows
      .Height = oRowHeight
      .HeightRule = wdRowHeightExactly
    End With
  End With
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-20-2011, 01:41 AM
boutells boutells is offline Auto fit tables to page Windows Vista Auto fit tables to page Office 2007
Novice
Auto fit tables to page
 
Join Date: May 2009
Posts: 24
boutells is on a distinguished road
Default

That works very well. Thank You
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to save the current page in a new file with all the page settings (header, footer Jamal NUMAN Word 6 03-15-2012 03:27 PM
Auto fit tables to page MS Word, page goes to next page when entering data on previous page munna94 Word 2 12-30-2010 08:12 AM
Auto fit tables to page Auto-Format Tables of Contents/Figures judicial85 Word 3 12-25-2010 02:02 AM
Auto fit tables to page Page break inside tables.(word 2003) englund33 Word Tables 1 06-15-2010 02:00 AM
Auto-updating basic math functions & cross-referencing tables FranklinBluth Word Tables 13 11-19-2009 10:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft