Powerpoint Event handling - Prevent New Presentation

I am creating a Powerpoint Add-in. I would like to restrict user from either:

  • Create New Presentation
  • Open an existing Presentation

I have used this tutorial/overview to trap the NewPresentation and PresentationOpen events. I would like to close any presentation initialized through these events before the user can interact with it. When I try to close it using .Close method, I receive an error (screenshot below).

In my class module, I have the following to trap the NewPresentation event. This works fine, I receive the message box and Pres is a valid Presentation object that can be passed to the CloseNewPres routine.

Private Sub PPTEvent_NewPresentation(ByVal Pres As Presentation)
MsgBox "You cannot use this Charting tool with multiple presentations.", vbInformation
CloseNewPres Pres
End Sub

In a standard module, I have the CloseNewPres routine, which I expect to close the "New" presentation:

Sub CloseNewPres(Pres As Presentation)
    Application.Presentations(Pres.Name).Close
    'Pres.Close '<~~ This also fails.'
End Sub

I receive the following error.

Any thoughts on why this is happening? Or what I can do to close these presentations?

Answers


In my opinion you need to use another event which is quite similar to one you used:

Private Sub PPApp_AfterNewPresentation(ByVal Pres As Presentation)

If I set Pres.Close within proposed one it really closes new created presentation.


Need Your Help

server unreachable from outside after IP change

table routing freebsd netstat

We changed a deal with our ISP and now they gave us a new IP.

Need to load jQuery UI Tabs dynamic content links through Ajax

jquery jquery-dialog jquery-tabs dynamic-links

I have this jQuery UI Tabs model with only 2 tabs and I need the content to load through Ajax. The problem is that these tabs are loaded inside a jQuery UI Dialog and mid is dynamic. I mean, the di...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.