Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-16-2017, 06:13 PM
Musab Musab is offline Help with Header/Footer Autosizing Windows 10 Help with Header/Footer Autosizing Office 2003
Novice
Help with Header/Footer Autosizing
 
Join Date: Nov 2017
Posts: 5
Musab is on a distinguished road
Default Help with Header/Footer Autosizing

Hi peoples,

Just need a hand on the following code, it formats all tables within a doc to adjust their width to the preset width (in the case below, 17.03 cm's). However, this code does not auto size the header and footer. Can someone give a hand?

Note: I use Different First Page for the coverpage of my word docs. Thanks peoples

"
Sub ConsistensifyTables()

Dim t As Table

'Show No markup
With ActiveWindow.View.RevisionsFilter


.Markup = wdRevisionsMarkupNone
.View = wdRevisionsViewFinal
End With

For Each t In ActiveDocument.Tables
With t
With .Rows
.Alignment = wdAlignRowCenter
.LeftIndent = CentimetersToPoints(0)
End With

.AutoFitBehavior (wdAutoFitFixed)
.PreferredWidthType = wdPreferredWidthPoints
.PreferredWidth = CentimetersToPoints(17.03)
End With
Next t

End Sub
"
Reply With Quote
  #2  
Old 11-17-2017, 01:51 AM
gmayor's Avatar
gmayor gmayor is offline Help with Header/Footer Autosizing Windows 10 Help with Header/Footer Autosizing Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You need to process all the story ranges separately e.g.

Code:
Option Explicit

Sub ConsistensifyTables()
Dim oStory As Range
Dim oTable As Table
    'Show No markup
    With ActiveWindow.View.RevisionsFilter
        .Markup = wdRevisionsMarkupNone
        .View = wdRevisionsViewFinal
    End With
    For Each oStory In ActiveDocument.StoryRanges
        For Each oTable In oStory.Tables
            With oTable
                With .Rows
                    .Alignment = wdAlignRowCenter
                    .LeftIndent = CentimetersToPoints(0)
                End With
                .AutoFitBehavior (wdAutoFitFixed)
                .PreferredWidthType = wdPreferredWidthPoints
                .PreferredWidth = CentimetersToPoints(17.03)
            End With
        Next oTable
        If oStory.StoryType <> wdMainTextStory Then
            While Not (oStory.NextStoryRange Is Nothing)
                Set oStory = oStory.NextStoryRange
                For Each oTable In oStory.Tables
                    With oTable
                        With .Rows
                            .Alignment = wdAlignRowCenter
                            .LeftIndent = CentimetersToPoints(0)
                        End With
                        .AutoFitBehavior (wdAutoFitFixed)
                        .PreferredWidthType = wdPreferredWidthPoints
                        .PreferredWidth = CentimetersToPoints(17.03)
                    End With
                Next oTable
            Wend
        End If
    Next oStory
lbl_Exit:
    Set oStory = Nothing
    Set oTable = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 11-18-2017, 03:25 AM
Musab Musab is offline Help with Header/Footer Autosizing Windows 10 Help with Header/Footer Autosizing Office 2003
Novice
Help with Header/Footer Autosizing
 
Join Date: Nov 2017
Posts: 5
Musab is on a distinguished road
Default

Thank heaps Graham, your code legit saves me like 5 minutes per document.

Solid answer and code.

Really appreciate it bud, you take care and keep up the good work.

Last edited by Musab; 11-18-2017 at 03:28 AM. Reason: Minor spelling error correction
Reply With Quote
Reply

Tags
header and footer, tables scaling sizing



Similar Threads
Thread Thread Starter Forum Replies Last Post
Header and Footer Diablodvs7 Word 1 07-28-2015 07:54 PM
Header and footer aligned in the footer area ashiqghfr Word 2 07-23-2015 01:14 AM
Help with Header/Footer Autosizing header footer Pierre-Hugues Word VBA 1 08-30-2013 06:06 AM
Help with Header/Footer Autosizing header & footer avi_sai Word 1 12-03-2011 10:52 AM
Different Header but same Footer Karthick Word 1 11-12-2010 09:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:32 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