Share via

GetPressedMso not reflecting ExecuteMso?

Anonymous
2015-08-14T08:37:39+00:00

I'm using PowerPoint 2007, trying to press buttons via VBA. Consider the following function:

    Sub ClickButton(str As String)

        CommandBars.ExecuteMso str ' execute respective button action

        Debug.Print CommandBars.GetPressedMso(str) ' retrieve button state after executing action

    End Sub

I expected the above function to do the following:

In PowerPoint 2007, if ShapeRectangle is already selected, a call to ClickButton("ObjectsSelect") prints False, even if we ExecuteMso prior to output. Still, ExecuteMso seems to work, because after the function is executed, ObjectsSelect is pressed in the ribbon.

Newer PowerPoint versions, or other buttons, seem to work as expected.

Is the behaviour in 2007 with ObjectsSelect documented somewhere? Or did I just encounter a bug?

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

7 answers

Sort by: Most helpful
  1. Anonymous
    2015-08-17T14:06:50+00:00

    Yes, I agree DoEvents is undesirable but in my experience PPT 2007 was bug prone because it was a rewrite. It got better with service packs.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-08-17T10:34:28+00:00

    I added a DoEvents just as you suggested and I actually observed the correct value printed by Debug.Print.

    Unfortunately, however, a DoEvents to me smells bad since it yields control to the operating system which can then process all incoming events (right?) which is highly nondeterministic and probably does more than I need resp. want. Moreover (and probably worse), I reduced my problem to VBA, but I'm actually coding in C++ (issuing calls to ExecuteMso/GetPressedMso from there). Of course, I could try to DoEvents or similar from C++, but it just seems a little too much for such a basic problem.

    I suppose I would like to know exactly which event is processed by DoEvents that ensures that the button is considered to be pressed afterwards.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-08-14T16:01:45+00:00

    Try including a DoEvents after CommandBars.ExecuteMso strspecifically for PPT 2007. My guess is that the first call hasn't updated the state before the GetPressedMso is invoked.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2015-08-14T15:22:22+00:00

    Hi, thanks for your hint, but unfortunately, I suspect that I already have the most recent service pack (SP3) istalled:

    • "About Microsoft Office PowerPoint 2007" indicates that Pp is: (12.0.6727.5000) SP3 MSO (12.0.6728.5000)
    • The executable's properties show version 12.0.6600.1000

    From what I've read, this means that I've installed SP3, which seems to be the most recent service pack.

    How did you execute ClickButton? (I tried it both via the immediate window and via a custom VBA function calling it explicitly.)

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2015-08-14T14:21:49+00:00

    Hi,

    I cannot repro this but I also have all the 2007 service packs installed. The original release of 2007 had a decent amount of bugs that got addressed with subsequent service packs. Are you up to date with the packs?

    Was this answer helpful?

    0 comments No comments