PowerPoint Question

E

Edvado

Hi, I have a complex macro/VBA project that runs in PowerPoint on the
visible main slide. The problem is, my users occasionally have one of
the thumbnails (left side of screen) clicked when the activate the code,
and the code blows up, not being able to find an object.

Is there anything I can do to shift the focus from any of the thumbnails
to the main slide? Oh, and by the way, the user may have inserted a new
slide, so I cannot simply select an object on the slide.


-Edvado
 
A

Andy Pope

Hi,

Can you make use of the ViewType property to check and set to a view
that allows your code to function?

[From Help file]

With Application.ActiveWindow
If .ViewType = ppViewNormal Then
.ViewType = ppViewSlideSorter
End If
End With

Cheers
Andy
 
E

Edvado

Andy Pope said:
Hi,

Can you make use of the ViewType property to check and set to a view
that allows your code to function?

[From Help file]

With Application.ActiveWindow
If .ViewType = ppViewNormal Then
.ViewType = ppViewSlideSorter
End If
End With

Cheers
Andy


I'll give it a try. Thanks.
 
S

Steve Rindsberg

Nah, they'd just point me to the VBA group.

No, they wouldn't.

But since you don't want to bother asking, you'll probably never learn that you
can do this:

Try to get a reference to the current slide:

Dim oSl as Slide
On Error Resume Next

Set oSl = ActiveWindow.Selection.SlideRange(1)

' If you can't get a reference to the slide
' then the cursor's between slides in Sorter view or
' in the slide pane
If oSl Is Nothing Then

' store the current view
lTemp = ActiveWindow.View.Type

' you may want to stop here if it's Master view
' so work that out:
If ActiveWindow.Panes.Count = 2 Then
' master view
Exit Function
Else
' normal view
lTemp = ppViewNormal
End If

' now switch views, then switch back
ActiveWindow.ViewType = ppViewNotesPage
ActiveWindow.ViewType = lTemp

' Now it's safe to use
' ActiveWindow.Selection.SlideRange(1).SlideIndex

End If
 
Top