Solved

How do I run a Powerpoint slide show using visual basic code?

Posted on 2007-11-17
6
2,936 Views
Last Modified: 2013-11-27
The goal is to run a powerpoint slide show by clicking a command button on a microsoft access database form.  I have attempted this several times with different pieces of code from searching online.  If there is an easier way to do it using just a macro and no code, then I am not that well-versed.  Here are some of the samples of code I have used with several different error messages:
  Function OpenPPTFile() As Boolean

    Dim stAppName As String

    stAppName = "C:\Documents and Settings\Blang\My Documents\Powerpointz\BLangBomberz.ppt"
    Shell stAppName, vbNormalFocus

    OpenPPTFile = True

End Function

Private Sub startSlideShow()

         Dim pptObject As PowerPoint.Application
         Dim pptPres As PowerPoint.Presentation
         Set pptObject = CreateObject("PowerPoint.Application")
         pptObject.Visible = True
         Set pptPres = pptObject.Presentations.Open("C:\Documents and Settings\Blang\My Documents\Powerpointz\BLangBomberz.ppt")
         pptObject.ActivePresentation.SlideShowSettings.Run
         Set PPT = Nothing

End Sub

The error I am getting is that the property is not set for automation operations.  Any help would be appreciated.  
0
Comment
Question by:blang476
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
Rick_Rickards earned 125 total points
ID: 20305500
Try this...


Private Sub startSlideShow()
    Dim objPPT As Object
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    objPPT.Presentations.Open ("C:\Documents and Settings\Blang\My Documents\Powerpointz\BLangBomberz.ppt")
    objPPT.ActivePresentation.SlideShowSettings.Run
    Set objPPT = Nothing
End Sub

Open in new window

0
 
LVL 21

Expert Comment

by:GlennaShaw
ID: 20305520
0
 

Author Comment

by:blang476
ID: 20305635
Perhaps my problem is in the Macro itself.  When I RunCode, what exactly am I to put in the Function Name?  I tried both startSlideShow and startSlideShow(), none of which were successful.  I am getting the same automation error as before.  I think it needs to be a Function and not a Sub, but not sure.  Thanks,
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:blang476
ID: 20305651
Never mind, I figured it out; it was in the macro itself.  the following code works though:
Private Sub startSlideShow()
    Dim objPPT As Object
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    objPPT.Presentations.Open ("C:\Documents and Settings\Blang\My Documents\Powerpointz\BLangBomberz.ppt")
    objPPT.ActivePresentation.SlideShowSettings.Run
    Set objPPT = Nothing
End Sub
0
 

Author Closing Comment

by:blang476
ID: 31409747
You must define the code as a Function and not a Sub procedure...
Thanks
0
 
LVL 16

Expert Comment

by:Rick_Rickards
ID: 20305772
Glad you got it working.  For what it's worth the code illustrated is version independent because it relies on Late Binding.  Thus, you need not be concerned about which version of Power Point the user has, it will simply look to and run whichever version the user happens to have installed.

Rick
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This video teaches viewers how to create handouts from their slides and helps them decide how many slides to include per handout.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question