请问,在VB中,如何执行poperpoint文档?谢谢

fou 2004-09-07 09:32:20
应该有这个功能的吧?
...全文
93 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangzhuo8888 2004-09-09
  • 打赏
  • 举报
回复
Private Sub Form_Load()

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

Form_Load_Error:
ErrHandler
Exit Sub
End Sub
starsoulxp 2004-09-07
  • 打赏
  • 举报
回复
方法一:
调用两个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

方法二:
在”工程\应用\"里面直接应用相应的可插入对象也可以!
End Sub
starsoulxp 2004-09-07
  • 打赏
  • 举报
回复
使用SHELL函数调用

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧