以幻灯片放映模式打开Powerpoint演示文稿



我想在幻灯片放映模式下直接打开幻灯片。我尝试使用的代码是:

Process.Start("powerpnt", "/s "str_Presfileopen)

'str_Presfileopen是一个字符串,包含文件的路径

但这行不通。它表示需要逗号")"或有效的表达式延续。

我尝试使用进程启动信息:

Dim Presfileopen As New ProcessStartInfo()
Process.Start("powerpnt", "/s " Presfileopen)

但这并不奏效。这里也说逗号")"或有效的表达式延续。

我到底做错了什么?作为一个测试,我在直接代码中编写,这很有效,但我不能这样做,因为我需要用户从列表中选择文件。有效的代码:

Process.Start("powerpnt", "/s ""a.pptx")

需要使用&+运算符将字符串连接在一起。您还需要在它周围加引号,以防文件名包含空格:

Process.Start("powerpnt", "/s """ & str_PresFileOpen & """")
Imports Microsoft.Office.Interop
Module Module1
Sub main()
    Dim pptPres As PowerPoint.Presentation
    Dim pptApp As PowerPoint.Application
    Dim file As String
    file = "C:myfile.ppsm" 'example location/file'
    pptApp = CreateObject("PowerPoint.Application")
    pptApp.Visible = True
    pptPres = pptApp.Presentations.Open(file)
End Sub
End Module 

请确保演示文稿属性设置为只读。

相关内容

最新更新