• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

I need to observe powerpoint actions in my OSX app

I need to observe powerpoint actions in my OSX app.
Scenario: I need to perform some actions in my OSX application when user clicks on save button in PowerPoint. Is there any ways to to this. I have achieved this functionality in Windows application by VBA Macro Events, but in PowerPoint Mac version the VBA Macro Events are not supported.
Thanks in advance
Please help me
0
Irshad KA
Asked:
Irshad KA
  • 3
  • 2
1 Solution
 
Jamie GarrochPowerPoint Consultant & DeveloperCommented:
You cannot use application events in Office:mac as they aren't supported (yet).

But, there is a way to get around this limitation for specific use cases with PowerPoint:mac 2016 (tested with build 15.26.160910) using the Repurpose Commands method. This allows you to hook into a command within the UI, as long as it's represented by a simple button in the interface, which File Save is.

This is how to do it:

1. Download CustomUI Editor from here
2. Create a new PowerPoint file
3. Open the VBE (Alt+F11)
4. Paste this code into a standard module
Option Explicit

'Callback for customUI.onLoad
Public Sub onLoadRibbon(ribbon As IRibbonUI)
  ' Do anything required when the ribbon is loaded
  Debug.Print "Ribbon loaded"
End Sub

'Callback for Save onAction
Sub RepurposeSave(control As IRibbonControl, ByRef cancelDefault)
  ' Do things when the user clicks the save button or invokes a save event e.g. via ctrl+s
  Select Case MsgBox("About to save this presenation." & vbCrLf & vbCrLf & _
                     "Are you sure you want to continue?", vbQuestion + vbYesNo, "Save Presentation")
    Case vbYes
      cancelDefault = False ' allow the presentation to be saved
    Case vbNo
      cancelDefault = True
    Case Else
      cancelDefault = True
  End Select
End Sub

Open in new window

5. Save as a macro-enabled .pptm file
6. Close the PowerPoint file
7. Run the Custom UI Editor and insert an Office 2010 Custom UI Part
8. Paste this code into the XML code pane:
<customUI onLoad="onLoadRibbon" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
	<commands>
		<command idMso="FileSave" onAction="RepurposeSave" />
	</commands>
</customUI>

Open in new window

9. Save the file
10. Reopen the file in PowerPoint:mac 2016
11. Accept to enable macros when asked:
PowerPoint:mac 2016 macro dialogue12. Click the save button to see this message:
PowerPoint:mac Save repurposed
The result is the attached file (I had to change the extension from .pptm to .zip to get EE to accept it):
Repurposing-Save-Command.zip
1
 
Irshad KASoftware EngineerAuthor Commented:
Thanks Jamie for this wonderful solution, working perfectly in powerpoint 2016 mac version.
But it is not working in powerpoint 2011 mac version. Is there any possible way to achieve this functionality in powerpoint 2011 mac version.
0
 
Jamie GarrochPowerPoint Consultant & DeveloperCommented:
The ribbon isn't extensible in Office:mac 2011 so no, there is no solution to detect the Save event in PowerPoint:mac 2011 as per this EE answer from a PowerPoint MVP:

https://www.experts-exchange.com/questions/28660552/VBA-application-events-or-equivalent-for-PowerPoint-mac-2011.html
1
 
Irshad KASoftware EngineerAuthor Commented:
Thanks Jamie Garroch
0
 
Jamie GarrochPowerPoint Consultant & DeveloperCommented:
You're welcome Irshad. If your happy with my response, please could you mark it as the answer?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now