Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-20-2015, 03:01 PM
mikemike616 mikemike616 is offline How to extend a table bottom border to the end of the page Windows 7 64bit How to extend a table bottom border to the end of the page Office 2013
Novice
How to extend a table bottom border to the end of the page
 
Join Date: Aug 2015
Posts: 7
mikemike616 is on a distinguished road
Default How to extend a table bottom border to the end of the page


I have a macro that adds a few cells to the end of a table. I need the bottom border of the added bottom row to extend to the end of the page with one line of text below it. Just below the table is a line of text that contains the string "DCR-0055". The code below accomplishes what I want to do but I think it is sloppy. It changes the cell row height rule to exact, and then in a while loop it adds .25 inches to the row height until the "DCR-0055" string is no longer on the page and then subtracts back enough space to put the line back on the same page.

Is there a better way to do this?

Code:
Set currentPage = ActiveDocument.Bookmarks("\Page").Range 
Dim heightValue As Single 
heightValue = 0.15 

Application.ScreenUpdating = False 

With ActiveDocument.Tables(tableNum).Cell(startX + 3, 1) 
    .HeightRule = wdRowHeightExactly 
    Do While InStr(currentPage, "DCR-0055") > 0 
        .SetHeight RowHeight:=InchesToPoints(heightValue), HeightRule:=wdRowHeightExactly 
        heightValue = heightValue + 0.25 
        Set currentPage = ActiveDocument.Bookmarks("\Page").Range 
    Loop 
    .SetHeight RowHeight:=InchesToPoints(heightValue - 0.45), _
        HeightRule:=wdRowHeightExactly 
End With 

Application.ScreenUpdating = True
Reply With Quote
  #2  
Old 08-20-2015, 08:08 PM
Guessed's Avatar
Guessed Guessed is offline How to extend a table bottom border to the end of the page Windows 7 32bit How to extend a table bottom border to the end of the page Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,966
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I don't know that this way is really any better but it is an alternative that might get you thinking. I was hoping I could use aRng.Information(wdVerticalPositionRelativeToPage) to make an elegant solution but I couldn't be bothered figuring it out properly
Code:
Sub Macro1()
  Dim aRng As Range, aCell As Cell
  Dim iCurrPage As Integer, lngPageHeight As Long
  
  Set aCell = ActiveDocument.Tables(1).Cell(1, 1)
  Set aRng = aCell.Range
  aRng.Collapse Direction:=wdCollapseEnd
  iCurrPage = aRng.Information(wdActiveEndPageNumber)
  
  aCell.HeightRule = wdRowHeightExactly
  lngPageHeight = aRng.Sections(1).PageSetup.PageHeight
  aCell.SetHeight RowHeight:=lngPageHeight, HeightRule:=wdRowHeightExactly
  Do Until aRng.Information(wdActiveEndPageNumber) = iCurrPage
    aCell.SetHeight RowHeight:=aCell.Height - 18, HeightRule:=wdRowHeightExactly
  Loop
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paginate table so cell headings appear top of page instead bottom page when no room bottom page mtcn Word Tables 5 12-11-2014 12:49 PM
How to extend a table bottom border to the end of the page Bottom border doesn't display at certain zoom Cosmo Word Tables 1 10-09-2013 10:38 AM
How to extend a table bottom border to the end of the page Aligning Page Border with Table border without losing formatting :mad: l39linden Word Tables 5 10-04-2013 02:06 AM
How to extend a table bottom border to the end of the page Aligning table with bottom of page Smallweed Word Tables 3 09-17-2013 08:24 AM
How to extend a table bottom border to the end of the page Anchoring a section break to the bottom of a page, and having a table pass over it??? h3rk Word Tables 1 11-20-2009 07:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:50 PM.


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