Wise Indian
Wise Indian

Reputation: 91

Opening Powerpoint Presentation in SlideShow Mode

I want to open a powerpoint directly in a slideshow mode. The code I am trying to use is this:

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

'str_Presfileopen is a string containing the path of the file

But this doesn't work. It says that Comma')' or a valid expression continuation expected.

I tried to use the process start info:

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

But this doesn't work as well. Here too it says that Comma')' or a valid expression continuation expected.

What the hell am I doing wrong? As a test I wrote in the direct code and this works but I can't do it like this because I need the user to select the file from a list. The code that works:

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

Upvotes: 0

Views: 3785

Answers (2)

mitchec
mitchec

Reputation: 1

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 

Make sure the presentation properties is set to read only.

Upvotes: 0

John Koerner
John Koerner

Reputation: 38077

You need to concatenate the strings together using the & or + operator. You also need to put quotes around it, in case the filename contains spaces:

Process.Start("powerpnt", "/s """ & str_PresFileOpen & """")

Upvotes: 1

Related Questions