【问题标题】:Using excel VBA to change format of headers/footers date and time in powerpoint使用 excel VBA 在 powerpoint 中更改页眉/页脚日期和时间的格式
【发布时间】:2020-04-10 19:22:01
【问题描述】:

我目前有以下设置。一切正常,除了 .DateAndTime.Format 没有更改幻灯片左下角的日期格式。日期显示为 2020 年 4 月 10 日,但我无法使用以下方法将其更改为 2020 年 4 月 10 日:

  Set PowerPointApp = GetObject(class:="PowerPoint.Application")
  Set myPresentation = PowerPointApp.Presentations.Add
    myPresentation.ApplyTemplate "[template file here]"
  Const ppSlideSizeA4Paper = 2
    myPresentation.PageSetup.SlideSize = ppSlideSizeA4Paper
  With myPresentation.SlideMaster.HeadersFooters

    .SlideNumber.Visible = True
    .DateAndTime.Visible = True
    .DateAndTime.UseFormat = True
    .DateAndTime.Format = ppDateTimeMMMMdyyyy

  End With

【问题讨论】:

    标签: vba powerpoint datetime-format headerfooter


    【解决方案1】:

    我认为您发现了一个错误,因为 VBA 不会更改主布局或其子布局上的日期格式。可以在幻灯片上设置:

    Sub DateTime()
        Dim oSlide As Slide
        For Each oSlide In ActivePresentation.Slides
            With oSlide.HeadersFooters
                .SlideNumber.Visible = True
                With .DateAndTime
                    .Format = ppDateTimeMMMMdyyyy
                    .Visible = msoTrue
                End With
            End With
        Next oSlide
    End Sub
    

    但是,当您插入新幻灯片时,日期仍会反映布局上设置的格式,您必须重新运行宏。

    【讨论】:

    • 我还有 PowerPoint 2003 的宏记录器。它在该版本中正常工作。
    • 哇,我不知道 2003 有一个宏记录器,太酷了。是的,在 365 中不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多