View Powerpoint Presentation Slides in Access Form 2010

Rita

New member
Local time
Yesterday, 19:13
Joined
Aug 22, 2013
Messages
4
Hi, this is my first post and I couldn't find this out there anywhere. I would like to know if there is any code to view existing Powerpoint presentations in an Access 2010 form . I am creating a library and would like to set this up. I would need step by step info as I am a beginner. I have seen code for 2007 and tried it but it didn't work for me. Can someone help me I'm working with Access & Powerpoint 2010. Please advise if I am not using the correct terms. I've seen VBA, Automation, etc.:rolleyes: I do not want to build ppt presentations in access.
 
Thank you for looking. Here is the code.

Option Compare Database

' Initialize variables.
Const firstSlide = 1
Dim arrSlideID() As Long
Dim pptobj As Object
Dim slideindex As Long, slidecount As Long

Sub ErrHandler()

Dim strError As String
Dim errObj As Error
strError = " "
If DBEngine.Errors.Count > 0 Then
For Each errObj In DBEngine.Errors
strError = strError & Format$(errObj.Number)
strError = strError & " : " & errObj.Description
strError = strError & " (" & errObj.Source & ") . "
strError = strError & Chr$(13) & Chr$(10)
Next
MsgBox strError
Else
MsgBox "Error: " & Err & " " & Error
End If

End Sub

Private Sub Form_Load()

On Error GoTo Form_Load_Error
Dim i As Integer
Dim holder As Long, present As Object

' Start Powerpoint and open an existing presentation.
holder = Shell("c:\Program Files\Microsoft Office\Office\Powerpnt.exe")
Set pptobj = CreateObject("PowerPoint.Application")
Set present = pptobj.Presentations.Open _
("C:\Users\rmclean.NDCBF.000\Desktop\2009 Easter Message.ppt")

' Determine the number of slides in the presentation.
slidecount = present.Slides.Count

' Fill an array with all Slide IDs.
ReDim arrSlideID(1 To slidecount)
For i = 1 To slidecount
arrSlideID(i) = present.Slides(i).SlideID
Next i

' Close the presentation.
pptobj.Presentations _
("C:\Users\rmclean.NDCBF.000\Desktop\2009 Easter Message.ppt").Close
Set present = Nothing
Exit Sub

Form_Load_Error:
ErrHandler
Exit Sub

End Sub

Private Sub Form_Unload(Cancel As Integer)

On Error GoTo Form_Unload_Error

' Close Powerpoint.
pptobj.Quit

Exit Sub

Form_Unload_Error:
ErrHandler
Exit Sub

End Sub

Private Sub frstSlide_Click()

On Error GoTo frstSlide_Click_Error

' Set SourceItem property to first slide and create a link.
With pptFrame
.SourceItem = arrSlideID(firstSlide)
.Action = acOLECreateLink
End With

slideindex = firstSlide

Exit Sub

frstSlide_Click_Error:
ErrHandler
Exit Sub

End Sub

Private Sub insertShow_Click()

On Error GoTo insertShow_Click_Error

' Make object frame visible and enable "navigation" buttons.
pptFrame.Visible = True
frstSlide.Enabled = True
lastSlide.Enabled = True
nextSlide.Enabled = True
previousSlide.Enabled = True

' Specify OLE Class, Type, SourceDoc, SourceItem and other
' properties.
With pptFrame
.Class = "Microsoft Powerpoint Slide"
.OLETypeAllowed = acOLELinked
.SourceDoc = "C:\Users\rmclean.NDCBF.000\Desktop\2009 Easter Message.ppt"
.SourceItem = arrSlideID(firstSlide)
.Action = acOLECreateLink
End With

' Set slide index to the first slide.
slideindex = firstSlide
frstSlide.SetFocus
insertShow.Enabled = False

Exit Sub

insertShow_Click_Error:
ErrHandler
Exit Sub
End Sub
End Sub

Private Sub lastSlide_Click()

On Error GoTo lastSlide_Click_Error

' Set SourceItem property to previous slide and create a link.
With pptFrame
.SourceItem = arrSlideID(slidecount)
.Action = acOLECreateLink
End With

slideindex = slidecount

Exit Sub

lastSlide_Click_Error:
ErrHandler
Exit Sub

End Sub

Private Sub nextSlide_Click()

On Error GoTo nextSlide_Click_Error

' Determine if current slide is last slide.
If slideindex < slidecount Then
slideindex = slideindex + 1

' Set SourceItem property to next slide and create a link.
With pptFrame
.SourceItem = arrSlideID(slideindex)
.Action = acOLECreateLink
End With
Else
MsgBox "This is the last slide."
End If

Exit Sub

nextSlide_Click_Error:
ErrHandler
Exit Sub

End Sub

Private Sub previousSlide_Click()

On Error GoTo previousSlide_Click_Error

' Determine if current slide is first slide.
If slideindex > firstSlide Then
slideindex = slideindex - 1

' Set SourceItem property to previous slide and create a link.
With pptFrame
.SourceItem = arrSlideID(slideindex)
.Action = acOLECreateLink
End With
Else
MsgBox "This is the first slide."
End If

Exit Sub

previousSlide_Click_Error:
ErrHandler
Exit Sub

End Sub


I get the following errors when open form and hit the 'Get Presentation' button.
Error 9: subscript out of range
Error 91: Object variable or with block variable not set
Error: 53 File not found
 
Last edited:
Hmm - difficult to read, you should have surrounded the code by using the Code Tag by clicking the "#"!
Where in you code is the code for the 'Get Presentation' button?
What I see is that there two "End Sub" just after each other.


insertShow_Click_Error:
ErrHandler
Exit Sub
End Sub
End Sub
Maybe it is better if you post your database with some sample data, (zip it).
 
Thank you. I have no experience with coding. I copied the coding steps from the microsoft website. The only thing I changed is the path of my powerpoint presentation. I surely hope you can help me. I erased the double 'end' on the script. Here is the link but I couldn't make it blue because I don't have 10 posts yet.

support.microsoft.com/default.aspx?scid=kb;en-us;210075
 

Users who are viewing this thread

Back
Top Bottom