Results 1 to 13 of 13
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PowerPoint: Controlling slides to be hidden (XP)

    I have a presentation with many animations. The problem with these is that if one looks at the slide in the "normal' mode but also if printed, the animated slides can be a real mess. On the other hand, from a communications & presentation point-of-view, animations are very powerful.

    I have the idea to have one presentation that can have two modes:

    (1) For presentation purposes it should HIDE all print optimized slides and show all animation slides. I could think of triggering this by the 'presentation-mode' event; then mark each slide could be pre-marked with something invisible (like a tranparent box, character etc). The VBA code would then show the slides marked for animation/presentation and hide these optimized for printing

    (2) For printing purposes, I want the animation slides hidden and the print optimize slides shown. This too could be triggered by the 'print' event or so

    Now, I'm basically experienced in EXCEL & Excel VBA but not in PowerPoint VBA. This seem like not such a difficult task but I was hoping someone could give me a jump start (or maybe a real expert who could create a quick piece of code that could basically do this)....

    Aprreciate and help and/or suggestions,

    Erik Jan

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    Check out the PPT VBA help for the Tags property of the Slide object. This sounds pretty relevant:
    <hr>Use Tags(index), where index is the name of a tag, to return a the tag value. The following example tests the value of the Region tag for all slides in the active presentation and hides any slides that don't pertain to the East Coast (denoted by the value "East").

    <pre>For Each s In ActivePresentation.Slides
    If s.Tags("region") <> "east" Then
    s.SlideShowTransition.Hidden = True
    End If
    Next</pre>

    <hr>
    Oddly, another page in the help file says always do the comparisons in UPPER CASE. So it's hard to know which Microsoft to believe. <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    OK... that helps... I've been playing a bit... here's some (very) simple questions on things I do not seem to be able to tackle right now....

    (1) How do I refer to the CURRENT slide in Powerpoint??

    (2) How do I read a TAG from the current slide only? What if that tag doesn't exist yet?

    (3) How do I change a TAG from the current slide only? What if that tag doesn't exist yet?

    Erik Jan

    PS. My Auto_Open doesn't seem to fire if I open a PPT.. is that me or am I missing something

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

    Re: PowerPoint: Controlling slides to be hidden (XP)

    PowerPoint doesn't have automatic macros in presentations, but see Make PPT respond to events.

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    Well yeah.. ok, I see that and actually have used an example from there to allow triggers (events) when I switch to presentation-mode and/or when I print. Problem is... these events need to be switched-on in the first place... in an example I got of one of the sites you mention, that required a manual action (clicking a button). I want to enable the event-class automatically (via Auto_Open?)

    Erik Jan

    PS. I'm using PowerPoint 2002

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

    Re: PowerPoint: Controlling slides to be hidden (XP)

    I think you would need an add-in for that.

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    > (1) How do I refer to the CURRENT slide in Powerpoint??
    I've struggled with this before, and I cannot remember. Hopefully some other code samples here have the secret.

    > (2) How do I read a TAG from the current slide only? What if that tag doesn't exist yet?
    Tags are a collection, so, doing this from general concepts, you'd first see if the .Tags.Count > 0 and, if so, you could look at .Tags(1) to see if it's the tag you want. You could have two tags, one named "Print" and one named "Show" and give them each a true or false value. Actually, if they have to be strings (this seems common), I guess that would be "True" or "False"

    > (3) How do I change a TAG from the current slide only? What if that tag doesn't exist yet?
    See notes under (2). One way is to use in-line error checking. If you look at examples of programming document properties, you might see that someone tries to set the property and, if it returns a certain error code, you then add the property. Or you could actually look in the collection. Since this is a small collection, it wouldn't burden the computer too much to check each tag on each slide (if any).

    Hope this helps.

  8. #8
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    In reference to question 1, current slide, here is a simple example. First add class module like this:

    Option Explicit
    Public WithEvents app As Application

    Once declaration entered you can add event procedures in class module. Example:

    Private Sub app_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    MsgBox "Slide " & Wn.View.Slide.SlideIndex, vbInformation, "Slide Number"
    End Sub

    This will display msgbox with slide number each time you advance to next slide. Before you can use application events, the class module must be initialized in a standard code module:

    Option Explicit
    Dim obj As clsEvents

    Public Sub InitializeEvents()

    Set obj = New clsEvents
    Set obj.app = Application

    End Sub

    The InitializeEvents sub (doesn't have to be named that) must be run once when presentation opened to enable events. In example clsEvents is name of class module. Sample sub to get slide number when in design (not Slide Show) mode:

    Public Sub WhereAmI()

    ' Called when in design mode (Document window):
    If ActiveWindow.ViewType <> ppViewNormal And _
    ActiveWindow.ViewType <> ppViewSlide Then
    ActiveWindow.ViewType = ppViewSlide
    End If

    MsgBox "Slide " & ActiveWindow.View.Slide.SlideIndex, vbInformation, "WHERE AM I"

    End Sub

    (This sub would be located in standard module.) Note test the active window's ViewType property before trying to get the SlideIndex number, displayed by msgbox. Refer to VBA Help for more info on using events in PowerPoint. Note: I am using PPT 2K, I think some new events were added in XP.

    HTH

  9. #9
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    Thanks, but isn't this allowing me to get the current slide in a slide show? What I was looking for is to get the current slide in 'normal' mode... The idea is (was?) that I have a piece of VBA code that triggers before presentation mode is entered. Then, for all slides the hidden property would be enabled / disabled based on the value of a TAG.

    However to be able to SET a tag, I'd also need a piece of code that I could start for each slide (individually, I guess in 'normal' mode) and that would ask me if the slide would be for presentation mode or print. That code should then add / change a tag which is for the CURRENT slide (in normal mode) only. Hence, I'd be looking for something like: ActiveSlide.Tag("Name").Value="Presentation"...
    I know, I know... "Activeslide" doesn't seem to exist... workarounds? Maybe I should go via presentation mode afterall (can I jump-in, make the change and exit back to normal mode unseen then)??

    Does this clarify a bit?? I'm sorry, maybe I want too much (but he... I'm used to Excel... there this would be a piece-of-cake)...

    Erik Jan

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    <P ID="edit" class=small>(Edited by jscher2000 on 30-Mar-04 19:05. Changed from Application.Windows(1) to ActiveWindow (not sure how I missed that the first time...).)</P>This window.selection approach seems to work when there's only one presentation open. Is it good enough for your needs?
    <pre>Sub CurrentSlideTagChecker()
    'Returns tags for the "current" slide in the "active" application window
    Dim sldCurrent As SlideRange, intCounter As Integer
    Set sldCurrent = ActiveWindow.Selection.SlideRange
    If sldCurrent.Tags.Count > 0 Then
    With sldCurrent.Tags
    For intCounter = 1 To .Count
    Debug.Print "Tag " & intCounter & " of " & .Count & _
    " for SlideNumber=" & sldCurrent.SlideNumber & _
    ": Name=" & .Name(intCounter) & ", Value=" & .Value(intCounter)
    Next
    End With
    Else
    Debug.Print "No tags for SlideNumber=" & sldCurrent.SlideNumber
    End If
    Set sldCurrent = Nothing
    End Sub</pre>

    Would be interested in seeing a more thoroughly tested solution. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  11. #11
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    Are these available? Can I make one... all I need is to fire some VBA code update PPT-load ("AutoOpen" behavior)

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    <P ID="edit" class=small>(Edited by jscher2000 on 31-Mar-04 10:35. )</P>I'm only familiar with COM Add-ins. These have a specific "on load" behavior that you can use to initialize your event handlers at a global level. You create and compile the COM Add-in using VB6 or Office Developer Edition.

    I wonder whether you could build a "generic" loader in a COM Add-in that would run a procedure of a specified name (such as, AutoOpen) when such a procedure is detected in a newly opened presentation. Wouldn't that be sweet? (Added: Or would it be a virus nightmare? Hmmm...) In the absence of such a generic loader, see the previous paragraph.

    There also are "PPA" style add-ins. I believe they are more like renamed presentation files, and do not need to be compiled. But I've never really dug into them in detail, so I don't know their capabilities.

  13. #13
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: PowerPoint: Controlling slides to be hidden (XP)

    To create a PPA add in...

    <UL><LI>Create your code in a normal PPT file, with no slides
    <LI>Create a Sub called Auto_Open() that initialises your code as required
    <LI>Save the PPT file
    <LI>File Save As... > Type PowerPoint Add-In (ppa). This will default to the correct addins folder
    <LI>Tools > Add Ins... > Add
    <LI>Select your new add in
    <LI>Select the check box next to your new add in[/list]Make sure that you keep the PPT version, as you can't edit the code in the PPA file.

    StuartR

Posting Permissions

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