admin管理员组文章数量:1300026
I am writing a macro to delete selected slides, i.e. clicked on, in the thumbnails pane of the Normal View.
There is always a selected slide even if none have been clicked on. If the macro is run, without selecting any slides, the default slide will be deleted. Need to detect that no slides have been selected and put up a warning msg box.
ActiveWindow.Selection.SlideRange.Count
returns 1, since there is always an active slide even if it's not clicked on. How do I detect that no slides are selected (clicked on) in the thumbnail pane?
Unless the user has specifically clicked between slides in the thumbnail pain of Normal view or in Slide Sorter view to select NO slides, there will always be a slide selected. So the problem becomes "How can I tell whether the user has deliberately selected a single slide or whether it just happens to be selected by default?"
Here is my code:
Sub DeleteSelectedslides()
ActiveWindow.Selection.SlideRange.Delete
End Sub
I am writing a macro to delete selected slides, i.e. clicked on, in the thumbnails pane of the Normal View.
There is always a selected slide even if none have been clicked on. If the macro is run, without selecting any slides, the default slide will be deleted. Need to detect that no slides have been selected and put up a warning msg box.
ActiveWindow.Selection.SlideRange.Count
returns 1, since there is always an active slide even if it's not clicked on. How do I detect that no slides are selected (clicked on) in the thumbnail pane?
Unless the user has specifically clicked between slides in the thumbnail pain of Normal view or in Slide Sorter view to select NO slides, there will always be a slide selected. So the problem becomes "How can I tell whether the user has deliberately selected a single slide or whether it just happens to be selected by default?"
Here is my code:
Sub DeleteSelectedslides()
ActiveWindow.Selection.SlideRange.Delete
End Sub
Share
Improve this question
edited Feb 17 at 22:40
Chris
137k133 gold badges305 silver badges283 bronze badges
asked Feb 11 at 15:56
Jerry VJerry V
215 bronze badges
6
- You are talking about Powerpoint? Please select the correct tags so that we can see what your question is about. – FunThomas Commented Feb 11 at 16:04
- Please also add the code you currently have. – Tim Williams Commented Feb 11 at 16:15
- Current code is: – Jerry V Commented Feb 11 at 19:14
- Sub DeleteSelectedslides() ActiveWindow.Selection.SlideRange.Delete End Sub – Jerry V Commented Feb 11 at 19:14
- I've edited your original post to help clarify your issue. Unless you've run into it before, it's hard to understand what you're asking. I don't think there's any way to distinguish between one deliberately selected slide and the current single slide the user's looking at, so the most reliable thing might be to pop a message box asking the user "OK to delete Slide 42? _ Yes _ No" – Steve Rindsberg Commented Feb 13 at 21:12
1 Answer
Reset to default 0My solution: If the active pane is not thumb nails, no slides selected.
Sub DeleteSelections()
If ActiveWindow.Selection.SlideRange.Count = 1 Then
If ActiveWindow.ActivePane.ViewType <> 11 Then
MsgBox "No Slides Selected"
End
End If
End If
ActiveWindow.Selection.SlideRange.Delete
'Do stuff
End Sub
本文标签: vbaMacro to delete selected slidesStack Overflow
版权声明:本文标题:vba - Macro to delete selected slides - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741650922a2390472.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论