Link to home
Start Free TrialLog in
Avatar of thenelson
thenelson

asked on

object in powerpoint 2003 not displaying

I have a Powerpoint 2003 slide with vba (uploaded: demo.ppt) with a problem I cannot figure out. I have an object (Group 82 - called inside arrow in the VBA) that I rotate and make visible using VBA. It shows up at certain rotations but not others. An outside arrow has identical code and works perfectly. To test the function in the demo slide, you need to have a number in the 10 index or 60 index textboxes. Then placing a number in the quantity textbox will display the outside arrow. Placing a number in the time textbox should display the inside textbox (but it doesn't always do that.)

If I manually make the inside arrow visible, then where it shows up changes but it will still not show up at all rotations. The inside arrow is on top of all other objects. I have tried remarking out all the lines of code that makes that object not visible and remarked out all the lines of code that change the visible property of that object (group 82).  I also tried deleting the problem object and recreated it. But the problem persists with everything I have tried.

This is driving me nuts. Any help would be appreciated.
demo.ppt
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)
Flag of United Kingdom of Great Britain and Northern Ireland image

Wow - what a great example of how VBA can add value to PowerPoint. You should write an article about this!

So I downloaded the file and in order to become familiar with what was going on, I found it easier to rename your on-slide objects (and do a corresponding search / replace on the code) as follows:

 User generated image
I can see the inner arrow appearing as you intend with some sample data so it's working for me. But, I have a small question. You mention that this is a PowerPoint 2003 slide but what version of PowerPoint are you using to view the slide show? In my test, I used 2016 (resaving the file as a digitally signed pptm format to deal with my security setup) but I recall that in the past, there was a change to the way groups and visibility are handled in VBA. I can't recall exactly which version that changed and the precise details but I think that you may need to reference the two sub-objects in the group for earlier versions of PowerPoint rather than the group object itself. Although this doesn't explain why it works for the outer and not inner arrow. the other thing I'm wondering if if you're suffering from a slide show refresh issue. If it's that, then there is a workaround whereby you add a shape to the slide (forcing PowerPoint to refresh the slide) and then delete it:

Private Sub RefreshSlide()
  With ActivePresentation.Slides(1)
    .Shapes.AddTextbox msoTextOrientationHorizontal, 1, 1, 1, 1
    DoEvents
    .Shapes(ActivePresentation.Slides(1).Shapes.Count).Delete
  End With
End Sub

Open in new window


If you can provide the version of PowerPoint you're using and example data where the inner arrow does not appear, I can look into it further.
ASKER CERTIFIED SOLUTION
Avatar of thenelson
thenelson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thenelson
thenelson

ASKER

Removing the animation and adding/deleting a shape did not help.
Putting the animation back in resolved the problem again.

Since I have a workaround that works, I am thinking of giving you the points to close the question.

But one additional quick question (I hope):
When one of the controls has focus (for example the Command Button "Clear All"), I can't advance the custom animation or advance to the next slide until I click somewhere on the slide to deselect the control. Anyway to automate this in VBA? IE: is there code I can put in the "Clear All" subroutine that will deselect the button?
A the end of the command button sub, set the button's visible property to false and then back to true. This should return focus to the slide.
That didn't work. The line was just ignored. I tried to set a textbox's visible property to false also but it too did not disappear. It looks like controls cannot be made invisible.
What happens is when the control's visible property is set to false, it doesn't disappear until leaving presentation mode.
That's weird. I couldn't test on 2003 as it's saying the controls are not registered on my machine (that's what happens when you try to trick Office into having multiple versions on the same machine!).

I did however test on 2007 and by adding a command button to a blank slide in a blank presentation, the hide and visible method works as described above so I'm not sure why it's not working for you in 2003. I would try adding the refresh workaround and see if that works e.g. call this at the end of your clear all button sub:

Private Sub RefreshSlide()
  Dim oShpTmp As Shape
  With ActivePresentation.Slides(1)
    .Shapes("CommandButton1").OLEFormat.Object.Visible = msoFalse
    Set oShpTmp = .Shapes.AddTextbox(msoTextOrientationHorizontal, 1, 1, 1, 1)
    .Shapes("CommandButton1").OLEFormat.Object.Visible = msoTrue
    DoEvents
    oShpTmp.Delete
    Set oShpTmp = Nothing
  End With
End Sub

Open in new window


It works on your file for 2007 but sorry I can't test it for 2003!
That code worked in 2003. I had to change:
   With ActivePresentation.Slides(1)
to
   With ActivePresentation.SlideShowWindow.View.Slide
to make it work on the current slide.

However it sets the  animation timeline back to the beginning. I was hoping for some code that keeps the  animation timeline at the same place which clicking on the slide at other than than a control. I know I could do it by calling an AutoHotkey script but that would be more work than its worth.
I have had feature issues if I had a basic default printer.  Once switched to a high end copier I had no problems.  Which is odd because I usually don't print PowerPoint slides.
Jamie,

I forgot to thank you for your help when  I closed out the question.

Thanks for your help.

Nelson
The solution was rotating the objects as soon as the slide opens.