Solved

I need to observe powerpoint actions in my OSX app

Posted on 2016-09-19
5
133 Views
Last Modified: 2016-09-20
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
Comment
Question by:Irshad KA
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
Jamie Garroch earned 500 total points
ID: 41806034
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
 

Author Comment

by:Irshad KA
ID: 41806234
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
 
LVL 10

Expert Comment

by:Jamie Garroch
ID: 41806305
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
 

Author Comment

by:Irshad KA
ID: 41806311
Thanks Jamie Garroch
0
 
LVL 10

Expert Comment

by:Jamie Garroch
ID: 41806345
You're welcome Irshad. If your happy with my response, please could you mark it as the answer?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This video teaches viewers how to create handouts from their slides and helps them decide how many slides to include per handout.
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question