调整Word中每个部分的标题内的表格

时间:2016-03-09 15:17:00

标签: vba ms-word word-vba

我有一个MS Word文档,只是为了有很多不同的标题。

发生我想在所有这些中进行一些调整,所以我带了下面的宏,但它似乎没有做任何事情。

    Sub FixHeaders()
    For i = 1 To ActiveDocument.Sections.Count
        If Sections(i).PageSetup.Orientation =wdOrientLandscape Then
            With ActiveDocument.Sections(i).Headers(wdHeaderFooterPrimary).Range.ParagraphFormat
                .SpaceBefore = 0
                .SpaceBeforeAuto = False
                .SpaceAfter = 0
                .Alignment = wdAlignParagraphLeft
            End With
            With ActiveDocument.Sections(i).Headers(wdHeaderFooterPrimary).Range.Font
                .Name = "Arial"
                .Size = 10
            End With
            With ActiveDocument.Sections(i).Headers(wdHeaderFooterPrimary).Range
                .LanguageID = wdEnglishUS
                .NoProofing = False
            End With
            Application.CheckLanguage = True
            With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1)
'******* Ajuste do Espaçamento das Linhas da Tabela **************
                .TopPadding = CentimetersToPoints(0.1)
                .BottomPadding = CentimetersToPoints(0.1)
                .LeftPadding = CentimetersToPoints(0.19)
                .RightPadding = CentimetersToPoints(0)
                .Spacing = 0
'******* Distribuição das Colunas**************
                .Rows.Alignment = wdAlignRowCenter
                .PreferredWidthType = wdPreferredWidthPercent
                .PreferredWidth = 99
                Selection.SelectColumn
                .Columns(1).PreferredWidthType = wdPreferredWidthPercent
                .Columns(1).PreferredWidth = 20.29
                Selection.Move Unit:=wdColumn, Count:=1
                .Columns(2).PreferredWidthType = wdPreferredWidthPercent
                .Columns(2).PreferredWidth = 57.63
                Selection.Move Unit:=wdColumn, Count:=1
                .Columns(3).PreferredWidthType = wdPreferredWidthPercent
                .Columns(3).PreferredWidth = 21.1
                Selection.Move Unit:=wdColumn, Count:=1
            End With
        End If
    Next
End Sub

请您就此提出任何建议吗?

0 个答案:

没有答案