【问题标题】:MS Word VBA dynamic footerMS Word VBA 动态页脚
【发布时间】:2012-08-11 15:07:13
【问题描述】:

我想替换页脚中的标签。它可以工作,但替换会删除页脚文本上方的水平线。 如何在不删除水平线的情况下替换标签? 如何在页脚中画一条线?

Private Sub Document_Open()
   Dim unit As String
   Dim footer As String
   unit = "New text"
   footer = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range.Text
   ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range.InlineShapes.AddHorizontalLineStandard   
   footer = Replace(footer, "<<Label>>", unit)
   ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range.Text = footer
End Sub

【问题讨论】:

    标签: vba footer ms-word


    【解决方案1】:

    有几种方法可以做你想做的事,在 VBA 中并不是所有的方法。到目前为止,您尝试过什么?

    如果您想使用 VBA 在文本上方画一条线,请将光标设置在您想要的位置,然后调用以下命令:

    With Selection.Borders(wdBorderTop)
        .LineStyle = Options.DefaultBorderLineStyle
        .LineWidth = Options.DefaultBorderLineWidth
        .Color = Options.DefaultBorderColor
    End With
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-09
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 2014-05-17
      • 1970-01-01
      相关资源
      最近更新 更多