码迷,mamicode.com
首页 > 其他好文 > 详细

How to automate PowerPoint using VB

时间:2014-06-25 14:28:25      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:des   http   com   get   string   art   

Microsoft has an article that explains how to automate PowerPoint using VB

For some odd reason they‘ve entitled it How to automate Powerpoint using VB

Here‘s a quick example:

Sub AutomatePowerPoint()
    ‘ This requires that you set a reference to PowerPoint in Tools, References
    ‘ You could later change these to As Object to avoid that necessity
    Dim oPPTApp As PowerPoint.Application   
    Dim oPPTPres As PowerPoint.Presentation
    Dim sPresentationFile as String

    sPresentationFile = "C:\MyFiles\Somefile.PPT"

    ‘ Get a reference to PowerPoint app
    Set oPPTApp = New PowerPoint.Application
    ‘  set it visible or you may get errors - there are ways around this but they‘re
   ‘  beyond the scope of this FAQ
    oPPTApp.Visible = True
    ‘ minimize if you want to hide it:
    ‘ oPPTApp.WindowState = ppWindowMinimized

    ‘ Open our source PPT file, get a reference to it
    Set oPPTPres = oPPTApp.Presentations.Open(sPresentationFile)

    With oPPTPres     ‘ Do stuff ...
      ‘ Show the number of slides in the file, for example  
      msgbox .Slides.Count           
    End With

    ‘ Cleanup
    ‘ Close the presentation
    oPPTPres.Close
    ‘ Quit PPT
    oPPTApp.Quit
    ‘ Release variables
    Set oPPTPres = Nothing
    Set oPPTApp = Nothing

End Sub

url:http://www.pptfaq.com/FAQ00115_How_to_automate_PowerPoint_using_VB.htm

How to automate PowerPoint using VB,布布扣,bubuko.com

How to automate PowerPoint using VB

标签:des   http   com   get   string   art   

原文地址:http://www.cnblogs.com/seasonzone/p/3806479.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!