Hi guys,
I'm trying to find a code in excel vba to exit powerpoint after my macro runs without saving it.
Thanks,
Hi guys,
I'm trying to find a code in excel vba to exit powerpoint after my macro runs without saving it.
Thanks,
Hi nguyenal07,
Some of the following code may help you:
Lewis![]()
Sub RunPowerPointSlideShowFromExcel() Const POWERPOINT_SHOWMINIMIZED = 2 Dim ppt As Object Dim pptFile As Object Dim sPowerPointPathAndFileName As String Dim iSlideNumber As Integer 'Change the following line for your PowerPoint folder and file name sPowerPointPathAndFileName = ThisWorkbook.Path & "\" & "ExcelForumPowerPointAutomation2.ppt" iSlideNumber = 2 Set ppt = CreateObject("PowerPoint.Application") ppt.Visible = True Set pptFile = ppt.Presentations.Open(Filename:=sPowerPointPathAndFileName) With pptFile.SlideShowSettings .ShowType = 3 '3 = ppShowTypeKiosk '.ShowType = 1 '1 = ppShowTypeSpeaker .RangeType = 1 '1 = ppShowAll .ShowWithAnimation = msoCTrue .LoopUntilStopped = msoFalse .AdvanceMode = 2 '2 = ppSlideShowUseSlideTimings .Run End With 'I know of no way to know when the slide show is completed unless: 'a. You control all the slides from the Excel Macro 'b. Excel/PowerPoint communicate and PowerPoint lets Excel know that the slide show has completed 'Minimize the PowerPoint Window If Not ppt Is Nothing Then ppt.WindowState = POWERPOINT_SHOWMINIMIZED End If 'Fool Powerpoint into thinking that changes to the PowerPoint file (if any) were saved 'Close the powerpoint presentation (file) If Not pptFile Is Nothing Then pptFile.Saved = True pptFile.Close End If 'Quit the PowerPoint application If Not ppt Is Nothing Then ppt.Quit End If 'Clear object pointers Set ppt = Nothing Set pptFile = Nothing End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks