He Here's given an article which will help to know "How to open a PowerPoint file through VBA" in MS Access. Through this code file open in Presentation mode and file mode.
This article explains through an example here:-
Firstly create a form with one button. When user click on this button then open an existing PowerPoint file in presentation mode whose path given in the code. Fig: - 1.1 show the form
Fig:-1.1
The code given below open a PowerPoint file in presentation mode.
Private Sub Command1_Click()
Call OpenPPT("Path of your PPT file", True)
End Sub
It will open a PowerPoint file in presentation mode. As shown in fig: -1.2
Fig:-1.2
you open an PowerPoint file in file editing mode then small change in the code as given below.
Private Sub Command1_Click()
Call OpenPPT("Path of your PPT file", false)
End Sub
It will open a PowerPoint file in file editing mode. As shown in fig: - 1.3
Fig:-1.3
Here is the VBA Code provided for open a powerpoint file through VBA:-
Private Sub Command1_Click()
Call OpenPPT("Path of your PPT file", True)
End Sub
Function OpenPPT(sFile As String, Optional bRunAsSlideShow As Boolean)
Dim oPPT As Object
On Error Resume Next
Set oPPT = GetObject(, "PowerPoint.Application")
If Err.Number <> 0 Then
Err.Clear
Set oPPT = CreateObject ("PowerPoint.Application")
End If
On Error GoTo Error_Handler
oPPT.Visible = True
oPPT.Presentations.Open (sFile)
If bRunAsSlideShow Then oPPT.ActivePresentation .SlideShowSettings.Run
Error_Handler_Exit:
On Error Resume Next
Set oPPT = Nothing
Exit Function
Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: OpenPPT" & vbCrLf & _
"Error Description: " & Err.Description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
DISCLAIMER
It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. ERP Makers will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.