读书人

用PB打开指定目录下的PPT文件解决方法

发布时间: 2012-03-15 11:50:38 作者: rapoo

用PB打开指定目录下的PPT文件
如题

[解决办法]
声明ShellExecuteA

FUNCTION ulong ShellExecuteA(ulong hwnd,ref string lpOperation,ref string lpFile,ref string lpParameters,ref string lpDirectory,ulong nShowCmd) LIBRARY "SHELL32.dll" ALIAS FOR "ShellExecuteA;Ansi"

---------

打开PPT按钮代码写:

string ls_path,ls_null
ls_path = 'D:\企管理5S管理.ppt'
setnull( ls_null )
shellexecuteA( handle(parent), ls_null, ls_path, ls_null, ls_null, 1 )

----
试验了 可行

[解决办法]
OLEobject ole_export
ole_export = CREATE OLEObject
long li_Return
string ls_xlsreport
ls_xlsreport = 'D:\企管理5S管理.ppt'

ll_find = iuo_file.FindWindowA(0, "microsoft powerpoint - " + ls_xlsreport)
if ll_find > 0 then
li_Return = ole_export.ConnectToObject(ls_xlsreport)
if li_Return = 0 then
ole_export.Application.DisplayAlerts = False
ole_export.application.quit()
ole_export.DisConnectObject()
end if
end if

//连结PowerPoint
li_Return = ole_export.ConnectToNewObject("powerpoint.application")
If li_Return <> 0 then
DESTROY ole_export
MessageBox("启动 PowerPoint","不能连结 Microsoft PowerPoint !")
return
end if

//PowerPoint显示
ole_export.Visible = true
ole_export.WindowState = 1

//开启PowerPoint档案
ole_export.documents.open(ls_xlsreport)//修改成下面语句
ole_export.Presentations.Open(ls_xlsreport)

上述代码的改动版,已经通过测试,可以打开指定的ppt文件




读书人网 >PB

热点推荐