在幻灯片中添加带有VBA的DateTime-Field

时间:2012-11-26 13:46:47

标签: vba powerpoint powerpoint-vba

我想通过宏在我的演示文稿/幻灯片中添加一个字段,自动显示当前日期。

 Shape shape = [Find a text shape to edit]
 shape.TextFrame.TextRange.Text = "Some Text  | " + [Field showing Current date]

我不想插入包含当前日期的文本:

 Shape shape = [Find a text shape to edit]
 shape.TextFrame.TextRange.Text = "Some Text  | " + DateTime.Now

正如我描述的那样,生成的texthape应该包含一些常量文本+一个显示当前日期的字段。

1 个答案:

答案 0 :(得分:3)

这会在文本框中插入时间/日期字段:

Dim oSh As Shape
Set oSh = ActiveWindow.Selection.ShapeRange(1)

With oSh.TextFrame.TextRange
    .Text = "Some text | "
    .InsertDateTime ppDateTimeHmm, True
End With