如何使用 VBA 将 Excel 中的未来 date/time 插入到 Powerpoint 中

How to insert future date/time from Excel into Powerpoint using VBA

我正在自动发送一封必须单独发送给 300 多人的信件。每个字母的名称不同,但日期和时间也不同。我使用 Excel 作为数据,并在 Powerpoint 中使用 VBA 来用正确的信息填充文本框。 日期保持格式为 6/27/2019。我需要它说 "June 27, 2019"。 当假设说“2:00 PM”时,时间保持格式为“0.583333333333333”。这些是我一直遇到的唯一问题。

我尝试将代码行更改为: oSld.Shapes("ClassDate").TextFrame.TextRange.Text = oWB.Sheets(1).Range("E2").NumberFormat = "mmm dd, yyyy"

这在 Powerpoint 的文本表单中提供了 'False'。还没想好怎么修改时间码

oSld.Shapes("MName").TextFrame.TextRange.Text=oWB.Sheets(1).Range("A2").Value
oSld.Shapes(“MName1”).TextFrame.TextRange.Text=oWB.Sheets(1).Range(“A2”).Value
oSld.Shapes("HAName").TextFrame.TextRange.Text = oWB.Sheets(1).Range("B2").Value
oSld.Shapes("HAName1").TextFrame.TextRange.Text = oWB.Sheets(1).Range("B2").Value
oSld.Shapes("WMWeek").TextFrame.TextRange.Text = oWB.Sheets(1).Range("D2").Value
oSld.Shapes("ClassDate").TextFrame.TextRange.Text = oWB.Sheets(1).Range("E2").Value
oSld.Shapes("ClassTime").TextFrame.TextRange.Text = oWB.Sheets(1).Range("F2").Value````


I expect the ClassDate output to be what is in range E2, June 27, 2019.
I expect the ClassTime output to be what is in range F2, 2:00 PM.

使用格式功能。两个例子:

...=Format(oWB.Sheets(1).Range("E2").Value,"MMM dd, yyyy")
...=Format(oWB.Sheets(1).Range("F2").Value,"hh:mm")

阅读文档中有关格式化代码的更多信息