[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2007-11-17
6
Medium Priority
?
3,003 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 375 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

650 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