Running Powerpoint

BlitzPlus Forums/BlitzPlus Programming/Running Powerpoint

Mental Image(Posted 2007) [#1]
Is it possible to run Powerpoint presentations from within Blitz+? I would like to run a scheduler so that I could pass the poerpoint filename as a parameter, and then have Blitz+ call powerpoint to display the *ppt file.


SebHoll(Posted 2007) [#2]
You could do it by bundling the freely distributable PowerPoint Viewer with your BlitzPlus application that your program can call, and by using switches, you can tell PowerPoint viewer what to do at startup.

PowerPoint Viewer 2003 Switches

Example:
ExecFile( "pptview.exe " + Chr(34) + "C:\mypowerpointfile.ppt" + Chr(34)) ;Show mypowerpointfile.ppt using PowerPoint viewer

However, the PowerPoint Viewer files will need to be in the same directory as your EXE.


Mental Image(Posted 2007) [#3]
Thanks for that, that's great - how do I call the switches? I would be grateful if you would give me an example showing, say, a single switch.


SebHoll(Posted 2007) [#4]
Basically, find the switch you need from the web page I posted and then you just add them to the end of the string you are executing (after the filename).

For example, to start a presentation from a specific slide (let's say slide 5 as an example), you'd do...

ExecFile( "pptview.exe " + Chr(34) + "C:\mypowerpointfile.ppt" + Chr(34) + " /n5" ) ;Start on Slide 5
Or, say you wanted to start the viewer without the splash screen (using /s) then you'd do...

ExecFile( "pptview.exe " + Chr(34) + "C:\mypowerpointfile.ppt" + Chr(34) + " /s" ) ;Start without the PowerPoint splash screen
Or maybe, you might want to do both:

ExecFile( "pptview.exe " + Chr(34) + "C:\mypowerpointfile.ppt" + Chr(34) + " /s /n5" ) ;Start at slide 5, without showing the PowerPoint splash screen
Hope this helps,

Seb


Petron(Posted 2007) [#5]
Seb, how do you add switches to your own application?


William Drescher(Posted 2007) [#6]
Program them in and then use the CommandLine() function to read through it and find the switches


Petron(Posted 2007) [#7]
Could you please post an example, the help manual example is somewhat shallow. Thanks


William Drescher(Posted 2007) [#8]
Ok

;Switch example

Global SwitchLine$ = CommandLine()
Global Switch1On = False
Global Switch2On = False
Global Switch3On = False

CheckForSwitches()

If Switch1On Then
    Print "Switch number 1 is on!"
Else
    Print "Switch number 1 is off!"
EndIf
If Switch2On Then
    Print "Switch number 2 is on!"
Else
    Print "Switch number 2 is off!"
EndIf
If Switch3On Then
    Print "Switch number 3 is on!"
Else
    Print "Switch number 3 is off!"
EndIf
WaitKey
End

Function CheckForSwitches()
	Res = Instr(SwitchLine$,"/s1",0)
	If Res = True Then
		Switch1On = True
	EndIf
	Res = Instr(SwitchLine$,"/s2",0)
	If Res = True Then
		Switch2On = True
	EndIf
	Res = Instr(SwitchLine$,"/s3",0)
	If Res = True Then
		Switch3On = True
	EndIf
End Function


Now put /s1, /s2, and/or /s3 in the command line and your good-to-go!

This code is kinda glitchy (like the Instr() function will find the switch even if it's in another word) and not very specific, but you get the idea.


Mental Image(Posted 2007) [#9]
Seb,

thanks for the information so far. However, I still have a couple of related problems. My application needs to run a list of Powerpoint files and, when the last one has been shown, start again at the beginning.

If I use the "/L" switch in Powerpoint Player, it exits after the last slideshow. If, however, I manage the list myself, I don't know whether there is already a slideshow running, so keep re-triggering the thing. I sort of need (pseudo code):

Repeat
     If {slideshow not already running}
          Execfile ("pptview.exe" + Chr(34) + MyFile + Chr(34) +"/S")
     Endif
Until Keyhit(1)


Thanks.


Petron(Posted 2007) [#10]
I could not get the switches to work for the example, of how to program switches. I used the same formatting as the power point example, can someone please pose what they used with the execfile command.