Excel

Run a Powerpoint Show From Excel

Ease of Use

Easy

Version tested with

2000, 2002 

Submitted by:

Justinlabenne

Description:

Run a pre-selected powerpoint show in a small window from within Excel 

Discussion:

This code is something you can use to display a small tour or even help information about your custom Excel application. All you need to do is write up whatever kind of information you want to deliver to your user via Powerpoint, save the Powerpoint file in the same location as the Excel file with the code, and run this code from your Excel app. It displays the Powerpoint show in a small window instead of taking up the whole screen. Clicking on the slides advances to the next slide the same as any regular Powerpoint show, and the user can still work within Excel while the show is displayed. The show just gets minimized to the taskbar. 

Code:

instructions for use

			

Option Explicit Public Sub RunThePowerpointTour() ' Constant for the title on the userform Const szAppName As String = "PowerPoint Window Tour" ' Constant for the Powerpoint file to load Const szShowName As String = "TestpptShow.ppt" ' PowerPoint Constant Const ppShowTypeInWindow = 1000 ' Late binding to avoid setting reference: Dim oPPTApp As Object Dim oPPTPres As Object ' Store this Excel file path, and add a path seperator if needed: Dim szShowPath As String szShowPath = FixTrailingSeparator(ThisWorkbook.Path) ' Create the path to the where the show should be: Dim szValidShowPath As String szValidShowPath = szShowPath & szShowName ' Initialize an instance of Powerpoint On Error Resume Next Set oPPTApp = CreateObject("PowerPoint.Application") ' If we got one okay, continue If Not oPPTApp Is Nothing Then ' With our new instance, open the preset ppt file: Set oPPTPres = oPPTApp.Presentations.Open(szValidShowPath, , , False) ' If it was found okay, continue on: If Not oPPTPres Is Nothing Then ' What to do with the presentation? With oPPTPres With .SlideShowSettings ' Show it in it's own window .ShowType = ppShowTypeInWindow ' Run it of course .Run End With End With Else ' if the presentation could not be shown: MsgBox "Presentation could not be found", 16, szAppName End If Else ' If Powerpoint is possibly not available on the machine: MsgBox "Powerpoint could not be found", 16, szAppName End If ' Explicitly clear memory Set oPPTApp = Nothing Set oPPTPres = Nothing End Sub Public Function FixTrailingSeparator(Path As String, _ Optional PathSeparator As String = "\") As String ' Xcav8r Select Case Right(Path, 1) Case PathSeparator FixTrailingSeparator = Path Case Else FixTrailingSeparator = Path & PathSeparator End Select End Function

How to use:

  1. Open an Excel Workbook
  2. Copy the code
  3. Press Alt + F11 to open the Visual Basic Editor (VBE)
  4. Select INSERT > MODULE from the menubar
  5. Paste code into the right pane
  6. Press Alt+Q to return to Excel
  7. Save workbook before any other changes
 

Test the code:

  1. Have powerpoint file named TestpptShow located in the same place as the Excel workbook with the code
  2. Go to TOOLS > MACRO > MACROS
  3. When the dialog appears, select (RunThePowerpointTour)
  4. Press Run
 

Sample File:

RunpptTour.zip 59.39KB 

Approved by mdmackillop


This entry has been viewed 387 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express