简体   繁体   English

如何使用VBA将Excel的将来日期/时间插入Powerpoint

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

I'm automating a letter that has to go out individually to 300+ people. 我正在自动处理一封必须单独发送给300多人的信件。 The names are different for each letter but dates and times are also different. 每个字母的名称不同,但日期和时间也不同。 I am using Excel for the data and using VBA in Powerpoint to fill the text boxes with the correct information. 我正在使用Excel来存储数据,并在Powerpoint中使用VBA来用正确的信息填充文本框。 The date keeps formatting to 6/27/2019. 日期保持格式为2019年6月27日。 I need it to say "June 27, 2019". 我需要说“ 2019年6月27日”。 The time keeps formatting to "0.583333333333333" when it is suppose to say "2:00 PM". 假定说“ 2:00 PM”时,时间保持格式为“ 0.583333333333333”。 These are the only issues I keep having. 这些是我唯一遇到的问题。

I've tried changing the line of code to this: oSld.Shapes("ClassDate").TextFrame.TextRange.Text = oWB.Sheets(1).Range("E2").NumberFormat = "mmm dd, yyyy" 我尝试将代码行更改为此: oSld.Shapes("ClassDate").TextFrame.TextRange.Text = oWB.Sheets(1).Range("E2").NumberFormat = "mmm dd, yyyy"

This provides a 'False' in the Text Form on Powerpoint. 这在Powerpoint的文本表单中提供了“ False”。 I have not figured out how to fix the time code. 我还没有弄清楚如何解决时间码。

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.

Use the Format function. 使用格式化功能。 Two examples: 两个例子:

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

Read more about the formatting codes in the documentation 在文档中阅读有关格式代码的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM