Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Restricting PPT addin to specifiic design template (VBA/Powerpoint/2000)

    I have created a powerpoint addin which does various bits and bobs, I would like it to only work with powerpoint files that have a certain design template attached to them. In my case "WM New.pot". I have no idea if this is possible at all?

    Many thanks

    thom

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Restricting PPT addin to specifiic design template (VBA/Powerpoint/200

    You could use the WindowActivate and WindowDeactivate events of the Application to control what happens. The template attached to the active presentation is

    ActivePresentation.TemplateName

    See Make PPT respond to events for an introduction to working with application events in PowerPoint.

  3. #3
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Restricting PPT addin to specifiic design template (VBA/Powerpoint/200

    Thanks HansV.

    I think i've managed to achieve what I want by including a custom property in the original template and then reading that property. i.e.

    Sub ReadProperty()
    On Error Resume Next
    'read "WM New" custom property value
    With Application.ActivePresentation
    If .CustomDocumentProperties("WM New") = False Then ActiveWindow.Selection.SlideRange.Shapes.AddShape( msoShapeRectangle, 108#, 270#, 72#, 72#).Select
    End With
    End Sub


    Though what i don't know how to do, is make this a global type thing rather that have it at the beginning of every Sub. Is this possible in any way?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Restricting PPT addin to specifiic design template (VBA/Powerpoint/200

    What would you like to make global? I assume that you will still have to test something at the beginning of every macro.

  5. #5
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Restricting PPT addin to specifiic design template (VBA/Powerpoint/200

    I only want the code to work on a document that has the custom property of "WM New" set at False, and it seems a bit cumbersome to have a bit of code before every sub routine (and there are lots in this add-in!), checking the document properties.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Restricting PPT addin to specifiic design template (VBA/Powerpoint/200

    I don't think you can avoid putting a test in each macro, but you can make it a bit more elegant by creating a function:

    Public Function IsWMNew() As Boolean
    On Error Resume Next
    IsWMNew = _
    (ActivePresentation.CustomDocumentProperties("WM New") = False)
    End Function

    At the beginning of each macro, add this line:

    If IsWMNew = False Then Exit Sub

  7. #7
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Restricting PPT addin to specifiic design template (VBA/Powerpoint/200

    That does tidy things up a lot.

    Many thanks for your help Hans.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •