用于更改文本框

时间:2016-03-26 22:21:43

标签: excel vba excel-vba powerpoint

我正在使用以下Excel VBA代码在当前当前功率点幻灯片中插入当前日期。现在,我可以在第二个文本框中的Powerpoint幻灯片中插入当前日期,但我无法根据我的要求更改日期格式。日期显示为2016年3月26日,而我必须像2015年3月26日那样修改它请注意,我没有在页脚边插入日期,我必须在文本框中添加日期。

Sub Date()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PPshape As PowerPoint.Shape
Dim objPPTX As Object
Dim Todate As Date                  
 Todate = DateValue(Now)

Todate = Format(Todate, "mmmm d, yyyy")''tried this

'or this ?
Todate = Format(CDate(Todate), "mmmm d, yyyy")'''Tried this also

Application.DisplayAlerts = False

Set objPPTX = CreateObject("PowerPoint.Application")
objPPTX.Visible = True
objPPTX.Presentations.Open "path.pptx"

'Adding Date on First Slide

Set PPApp = GetObject(, "Powerpoint.Application")
    Set PPPres = PPApp.ActivePresentation
    PPApp.ActiveWindow.ViewType = ppViewSlide
    PPApp.Visible = True
     Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex) ''copy chart on existing slide

Set PPshape = PPSlide.Shapes.AddShape(Type:=msoShapeRectangle, Left:=220, Top:=150, Width:=270, Height:=75)
With PPshape
.Fill.ForeColor.RGB = RGB(115, 111, 112)
.TextFrame.TextRange.Text = Todate
Todate = Format(Todate, "mmmm d, yyyy")
'or this ?
Todate = Format(CDate(Todate), "mmmm d, yyyy")
.TextFrame.TextRange.Font.Name = "Arial"
.TextFrame.TextRange.Font.Color = vbYellow
.TextFrame.TextRange.Font.Size = 18

End Sub

2 个答案:

答案 0 :(得分:0)

与问题中提到的Excel VBA代码相关,解决方案可以如以下示例所示:

// do the encryption
let keyPair = tweetnacl.sign.keyPair();
let publicKey = tweetnacl.util.encodeBase64(keyPair.publicKey);
let signature = tweetnacl.util.encodeBase64(tweetnacl.sign.detached(tweetnacl.util.decodeUTF8(certData), keyPair.secretKey));
let secretKey = tweetnacl.util.encodeBase64(keyPair.secretKey);
let encryptedSecretKey = CryptoJS.AES.encrypt(secretKey, this.props.data.password).toString();

答案 1 :(得分:0)

这是你的问题。您正在将文本框的文本设置为Todate,然后更改Todate的格式:

.TextFrame.TextRange.Text = Todate
Todate = Format(Todate, "mmmm d, yyyy")

而是试试这个:

.TextFrame.TextRange.Text = Format(Now, "mmmm dd, yyyy")