Consulting

Results 1 to 4 of 4

Thread: Macro won't run on a linked presentation

  1. #1

    Macro won't run on a linked presentation

    Hi all,

    I'm using Powerpoint 2010 and have set up two seperate presentations.

    One is being used daily as a briefing tool The second seperately as a training tool.

    The latter for training is setup is used to generate aircraft emergency captions. It has a main front end slide (splash screen) with two areas (drawn on as buttons) where you can select a random emergency or a specific emergency to discuss. The 'specific' slides are access by right clicking on the button and simply selecting the slide you want from the list. The random button slide powerpoint is generated by simple VBA code shown below.

    Sub JumpToRandomSlide()

    Dim SldRng As Integer
    Dim SldStart As Integer

    'Number of slides in the range
    SldRng = 20

    'First slide in that range
    SldStart = 20

    'Do It
    SlideShowWindows(1).View.GotoSlide _
    Int(Rnd() * SldRng) + SldStart

    End Sub

    This works perfectly in isolation when opened up normally and is ideal for our requirements. Each time the radnom button is pressed a different emergency slide is displayed...perfect !

    Occasionally we access the emergency presentation from the standard briefing presentation. It is accessed using an action button that hyperlinks directly to the emergency presentation. The main splash screen opens up where the random button is displayed as you would expect, if you click on it it will not run the 'random' macro and the same slide is presented time after time.

    I have searched high and low for answers and come up with nothing. I have treid copying the VBA code to the briefing powerpoint as well which has had no effect.

    I must admit I'm new to coding and there may be something simple I'm missing out on. I've tried it on differenet machines but I keep getting the same result.

    If you have any advice or things to try I'd appreciate it.

    Thanks

    Lee

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Is the presentation with the random slides saved as a pptm file?
    Are you sure macro security is set low enough to run the macro?
    In PowerPoint goto File > Options > Trust Center> Trust Center Settings > protected View and temporarily deselect everything and see if it helps.

    BTW

    As written your code will normally show the same sequence of slides.

    TRY:

    Sub JumpToRandomSlide()

    Dim SldRng As Integer
    Dim SldStart As Integer

    'Number of slides in the range
    SldRng = 20

    'First slide in that range
    SldStart = 20

    'Do It
    Randomize
    SlideShowWindows(1).View.GotoSlide _
    Int(Rnd* SldRng) + SldStart

    End Sub

    Probably worth saying how sldRng is defined because it doesn't look like the correct formula for a random slide
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    John,

    Thank you very much for your reply.

    The presentation was already saved as a pptm file, and the security settings set according.

    I tried running the new code and it worked first time. I've been testing it for the last hour on and off and all seems well so thank you very much.

    There didn't seem to be too many changes, and always trying to learn could you explain briefly what you changed please and why?

    Regarding the SldRng, I don't fully understand. There are 93 slides in total, should this reflect that number?

    Thanks again for your help, much appreciated.

    Lee

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    The formula to jump to a random slide between Lowest Slide and Highest Slide is: (I think!)

    Int((highest slideNo - one less that lowest slide number)*rnd) + lowest slide number
    So to jump to a slide between 73 and 93

    Int((21)*rnd) +73

    rnd is always between 0 and 1 (can be 0 but never 1)

    Int(21* rnd) is 0 to 20

    Add 73 gives 73 to 93
    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
  •