Share via

ActivePresentation returns wrong presentation when multiple presentations are open

Anonymous
2014-09-02T12:12:34+00:00

I have got a VBA PowerPoint add-in which has a custom ribbon bar tab.  Many of the options on the ribbon bar use ActivePresentation to get the presentation the user currently has open.

ActivePresentation doesn't appear to work if the user has multiple presentations open though.  In this case, ActivePresentation returns the presentation the user first opened and not the one that they've got open when they click the option on the ribbon bar. It appears as if the add-in is somehow tied to the presentation that launched the add-in.

If I then close the first presentation that was opened, ActivePresentation then works correctly returning the presentation that the user currently has their cursor in.

Has anyone come across this problem?  Is there something I need to do to make the add-in realise that the active presentation is the one that the user currently has the cursor in rather than the one that they initially opened?

TIA

Julie

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2014-09-03T07:06:25+00:00

I can see how that might happen if the form was still loaded (even if hidden) in a presentation it might activate it when called.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

11 additional answers

Sort by: Most helpful
  1. Anonymous
    2014-09-03T10:55:56+00:00

    Glad we got there in the end! 10/10 for quick accurate reponses too!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-09-03T07:59:51+00:00

    Hi John

    You're completely right - I was simply hiding the form - if I unload it instead, it works perfectly with multiple presentations.

    Many thanks for pointing me in the right direction.

    Julie

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-09-03T06:52:05+00:00

    Hi John

    The add-in is pretty complex so it isn't that easy to share the code. However, I've just spent some time creating a test add-in stripping out my code to the bare minimum which has helped me track down the cause of the issue.

    It looks the issue is caused by a progress bar I have implemented.  The button on the ribbon bar now simply calls the following sub:

    Public Sub GetActivePresentation()

        ' display progress bar

        With frmProgressBar

            .ProgressBar1.Value = 0

            .ProgressBar1.min = 0

            .ProgressBar1.max = 20

            .Caption = "Progress"

            .lblMessage.Caption = "Calculating. Please wait..."

        End With

        frmProgressBar.Show vbModeless

        MsgBox ActivePresentation.FullName

        frmProgressBar.Hide

    End Sub

    If I remove the frmProgressBat stuff, ActivePresentation.FullName gives me the correct result but if I leave it in, ActivePresentation.FullName always gives me the name of the first presentation I opened.

    At the moment, I'm assuming that the window my progress bar is in is associated with the first presentation somehow rather than the actual active presentation. 

    Now that I've worked out it's the progress bar that's the problem, hopefully I'll be able to find a work-around to it.

    Julie

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-09-02T13:56:29+00:00

    Is it code you are able to share?

    Was this answer helpful?

    0 comments No comments