On Error GoTo Form_Load_Error
Dim holder As Long, present As Object
' Start Microsoft Powerpoint and open an existing presentation.
holder = Shell("c:\msoffice\powerpnt\powerpnt.exe")
Set pptobj = CreateObject("PowerPoint.Application")
Set present = pptobj.Presentations.Open _
("c:\msoffice\powerpnt\pptexample.ppt")
' Determine the number of slides in the presentation.
slidecount = present.Slides.Count - 1 + FIRSTSLIDE
' Close the presentation. Use only 1 of the following lines
'Office 97 Syntax
pptobj.Presentations _
("c:\msoffice\powerpnt\pptexample.ppt").Close
'Office 7.0 Syntax
present.Close
Set present = Nothing
Exit Sub
方法一:
调用两个API函数“shellexecute"和"getdesktopwindow"
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Const SW_SHOWMAXIMIZED = 3
Private Sub Command1_Click()
Dim pat
pat = "c:\1.ppt" '假设是你所放文件的路径
ShellExecute GetDesktopWindow(), "open", pat, pat, "C:\", SW_SHOWMAXIMIZED