If Statement

T

Tyron

This is what I need

If no slide is selected then to come up with a message "please select a
slide"

This is my current code which works fine, only if a slide is selected,
otherwise a error message comes up saying nothing is selected.

Private Sub TableA_Click()
With Presentations.Open("G:\Tyronne Soanes\Testingb.ppt", msoFalse)
.Slides(54).Shapes.Range(Array("Text Box 7", "Rectangle 3", "Object
9")).Copy
.Close
End With
ActiveWindow.Selection.SlideRange(1).Shapes.Paste
End Sub
 
D

David M. Marcovitz

You can use something like this:

If ActiveWindow.Selection.Type = ppSelectionSlides Then
MsgBox "some slides"
Else
MsgBox "no slides"
End If

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
D

David M. Marcovitz

Note that this solution only works in slide sorter view where you would
select one or more slides. I think the alternative is to try something
with ActiveWindow.Selection.SlideRange and use the error handling
(OnError Goto ....).
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
S

Steve Rindsberg

David M. said:
Note that this solution only works in slide sorter view where you would
select one or more slides. I think the alternative is to try something
with ActiveWindow.Selection.SlideRange and use the error handling


This may help:

' The idea is to have a reference to the parent slide no matter what's selected
Dim oSl As Slide

Select Case ActiveWindow.Selection.Type
Case Is = ppSelectionText
Set oSl = ActiveWindow.Selection.TextRange.Parent.Parent.Parent

Case Is = ppSelectionNone
Set oSl = ActiveWindow.View.Slide

Case Is = ppSelectionShapes
Set oSl = ActiveWindow.Selection.ShapeRange(1).Parent

Case Is = ppSelectionSlides
Set oSl = ActiveWindow.Selection.SlideRange(1)

End Select

The whole thing needs to be surrounded with some error trapping in case the
user's clicked in the outline view. There may be other buglets lurking as
well, but it's a start.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top