尝试访问powerpoint并使用VBScript在幻灯片中添加文本

时间:2012-09-21 12:01:30

标签: vbscript ms-office powerpoint

任何人都可以给我发送代码,如何使用vbscript在现有的power point中添加文本?​​

提前致谢。

1 个答案:

答案 0 :(得分:0)

检查这些文章中的一些指示:

How to automate PowerPoint by using Visual Basic - Microsoft Support Microsoft Kb kb/555191

Automating a Powerpoint Presentation using VBA

代码的基础知识是这样的:

Dim oPPt, oPPs
Set oPPt = CreateObject("PowerPoint.application")
oPPt.Visible = True
' Assuming your adding it to an existing powerpoint : '
Dim sPPtFile: sPPtFile = "C:\yourPowerpoint.pptx"
Set oPPs = oPPt.Presentations.Open(sPPtFile)

Dim oSlide
Set oSlide = oPPs.Slides.Add(1, 2)
oSlide.Shapes(1).TextFrame.TextRange.Text = "My first slide "

oPPTFile.SaveAs "C:\yourPowerpointUpdated.pptx" 
oPPt.quit
set oPPt = nothing