Consulting

Results 1 to 2 of 2

Thread: VBA code when click on PowerPoint last slide then open Word document

  1. #1
    VBAX Newbie
    Joined
    Jan 2020
    Posts
    1
    Location

    VBA code when click on PowerPoint last slide then open Word document

    Hi,

    I am a trainer and have about 100 training modules in Powerpoint 2016.
    I also have a Word page in which every presentation is listed. The idea is that I click on a link in Word that will open the Powerpoint presentation. No problems so far, this all works.
    However, what I want to achieve is the following:

    When I come to the last slide of the pptm presentation and I click the mouse or clicker then this action should close the Powerpoint presentation and open up the Word document that contains the index of the presentations.

    I do not want to create an object on the last page that physically needs to be clicked. No, just when I progress to the last page and I click the mouse (Or clicker) then the action will need to happen.

    So far I created this code but it doesn't work. Most likely due to the fact that I'm not familiar with the nomenclature in Powerpoint objects.

    Sub ReturnToMenu()
    Dim sld As Slide
    Set sld = Application.ActiveWindow.View.Slide
    'With sld = Application.ActiveWindow.View.Slide _
    .ActionSettings(ppMouseClick)

    With sld.ActionSettings(ppMouseClick)
    .Action = ppActionHyperlink
    .Hyperlink.Address = "G:\- Course modules\Modules list.docx"
    End With
    End Sub

    Can somebody help please?
    Thank you very much in advance!
    Cheers,

    Luke

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Slides do not have ActionSettings so your code cannot work.

    You might be able to use code which runs when you get to the last slide

    Sub OnSlideShowPageChange(SW As SlideShowWindow)
    ' you must add an item from the Control Toolbox on
    ' Slide 1 and set to NOT VISIBLE
    If SW.View.CurrentShowPosition = ActivePresentation.Slides.Count Then
    MsgBox "Last Slide"
    End If
    End Sub
    Obviously replace the msgBox witht he Hyperlink code.

    Unfortunately this pseudo event is not reliable (it dates from PPT 97) and you must add an item from the control toolbox to the first slide and set it to NOT VISIBLE in the selection pane. It will appear to work without this but it will eventually fail unless you do this.

    If you use this a lot the best solution would be to create an AddIn that detects that the presentation has a link to word and opens it when the last slide displays. Not so easy but definitely works.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •