Solved

I need to observe powerpoint actions in my OSX app

Posted on 2016-09-19
5
93 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 9

Accepted Solution

by:
Jamie Garroch earned 500 total points
Comment Utility
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
Comment Utility
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 9

Expert Comment

by:Jamie Garroch
Comment Utility
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
Comment Utility
Thanks Jamie Garroch
0
 
LVL 9

Expert Comment

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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Modern/Metro styled message box and input box that directly can replace MsgBox() and InputBox()in Microsoft Access 2013 and later. Also included is a preconfigured error box to be used in error handling.
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now