Search code examples
vb.netprocessslideshowpowerpoint

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")

Solution

  • 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 & """")