Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-27-2022, 09:02 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with Tables in All Headers in Every Section - Remove cell's padding Windows 10 Help with Tables in All Headers in Every Section - Remove cell's padding Office 2019
Competent Performer
Help with Tables in All Headers in Every Section - Remove cell's padding
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default Help with Tables in All Headers in Every Section - Remove cell's padding

Hello Pros,


I got this 110 pages document, where almost all pages has a sections break with the headers having a different name.

What is annoying, is that it's put Cell inside padding space. I was able to create a macro to remove all tables padding. But lot's of tables still had space in there. Not even consistant from one page to another. I'm so fedup to fix them one page at the time.
What you need to know, every page that has a table in the header, its between 2 rows to 4 rows.

I've created a macro to fix the cell padding, but I've created a problem, that it kept staying at that section page. I've tried with F8, step by step, and yup, it stayed stuck there.

Code:
    Dim lngIndex As Long
    Dim oSec As Section
    Dim oHead As HeaderFooter
    Dim i As Integer

     For Each oSec In ActiveDocument.Sections
         For lngIndex = 1 To 3
         
            For Each oHead In oSec.Headers
               If oHead.Exists Then
               For i = oHead.Range.Tables.Count To 1 Step -1
          
                  With oHead.Range.Tables(i)
                  
'***Removes cells padding too
                Dim oCell As Cell
                Dim oTable As Table
                 Set oTable = Selection.Tables(1)
                 For Each oCell In oTable.Range.Cells
                     With oCell
                        .TopPadding = (0)
                        .BottomPadding = (0)
                        .LeftPadding = (0)
                        .RightPadding = (0)
                     End With
                 Next oCell
                  End With
   
               Next i
               End If
            Next oHead
    On Error GoTo 0
  
    Next
  Next

lbl_Exit:
  Exit Sub


By the way, I'll share which one works, it's to remove all table padding from every section. So if this could be done also for the Cells paddings.
I've created to test the tables in the headings, to place 1 space after each row. It works

Code:
  
    Dim lngIndex As Long
    Dim oSec As Section
    Dim oHead As HeaderFooter
    Dim i As Integer

     For Each oSec In ActiveDocument.Sections
         For lngIndex = 1 To 3
         
            For Each oHead In oSec.Headers
               If oHead.Exists Then
               For i = oHead.Range.Tables.Count To 1 Step -1
                'oHead.Range.Tables(i).Delete
                 oHead.Range.Tables(i).Rows.HeightRule = wdRowHeightAuto
                 oHead.Range.Tables(i).Rows.Height = InchesToPoints(0)
                 oHead.Range.Tables(i).Range.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
                 oHead.Range.Tables(i).Range.ParagraphFormat.SpaceBefore = 0
                 oHead.Range.Tables(i).Range.ParagraphFormat.SpaceAfter = 1
          
                 'With Selection.Tables(1)
                  With oHead.Range.Tables(i)
                    .TopPadding = InchesToPoints(0)
                    .BottomPadding = InchesToPoints(0)
                    .LeftPadding = InchesToPoints(0)
                    .RightPadding = InchesToPoints(0)
                    .Spacing = 0
                    .AllowPageBreaks = True
                    .AllowAutoFit = False
                  End With
   
               Next i
               End If
            Next oHead
    'Next oSec
    On Error GoTo 0
  
    Next
  Next

lbl_Exit:
  Exit Sub
Anyway, if any chance you may tell me if it's doable to add or a separate macro to remove all section header tables cell's padding to 0" on each sides, and guide me where I'm going wrong, I would be soooooooo appreciative it

Cendrinne
Reply With Quote
 

Tags
cells padding removal, help me;



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Tables in All Headers in Every Section - Remove cell's padding Macro to change each individual cell to 0 padding, one at a time in a table with merged cells. Wild Bee Word VBA 3 02-10-2021 12:44 AM
Help with Tables in All Headers in Every Section - Remove cell's padding Headers and footers cross section breaks baymoon Word 2 05-15-2017 09:01 PM
Help with Tables in All Headers in Every Section - Remove cell's padding Typesetting agony: section breaks, footers, and headers, oh MY... thesun Word 6 05-29-2015 11:55 AM
Help with Tables in All Headers in Every Section - Remove cell's padding remove headers and footers ghphoto Word 2 02-22-2015 05:49 PM
Help with Tables in All Headers in Every Section - Remove cell's padding Using Pagination, Headers and Section Endnotes Simultaneously DBinSJ Word 4 05-01-2012 02:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:58 PM.


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