简体   繁体   English

VBA代码删除带有空白布局PowerPoint的所有幻灯片?

[英]Vba code to delete all slides with a blank layout powerpoint?

Looking for an example vba code that deletes all slides with a blank layout. 寻找一个示例vba代码,该代码删除所有空白布局的幻灯片。

I am trying to create a catalog using a UserForm. 我正在尝试使用UserForm创建目录。 The user selects which products they want to look at and the code deletes the slides of the products they don't want to look at. 用户选择他们想要看的产品,并且代码删除他们不想看的产品的幻灯片。

The problem is that if I delete the array of slides specific to a product, it changes the total number of slides and then the other slide number arrays no longer contain the slides specific to the other products. 问题是,如果我删除特定于产品的幻灯片数组,则会更改幻灯片的总数,然后其他幻灯片编号数组不再包含特定于其他产品的幻灯片。

I was thinking I would add blank slides in place of the undesired slides and then delete all of the blank slides at the end. 我当时想添加空白幻灯片来代替不需要的幻灯片,然后最后删除所有空白幻灯片。

I am open to other ideas and suggestions. 我愿意接受其他想法和建议。 Thank you for your time and assistance. 感谢您的时间和协助。

It sounds as though you're working with arrays of SlideNumber or SlideIndex. 听起来好像您正在使用SlideNumber或SlideIndex数组。
Never bother with SlideNumber for various reasons. 切勿因各种原因而烦恼SlideNumber。 And in this case, SlideIndex will change after you delete slides. 在这种情况下,删除幻灯片后,SlideIndex将会更改。

Instead, either work with arrays of Slide objects or instead of SlideIndex, use an array of SlideId ... SlideIds are assigned when the slide is created and never change. 而是使用Slide对象的数组或代替SlideIndex,而使用SlideId的数组... SlideId在创建幻灯片时分配,并且永不更改。

Example of how to find a slide from its SlideID, in this case, 258 arbitrarily: 如何从其SlideID查找幻灯片的示例(在本例中为258):

Dim oSl As Slide
Set oSl = ActivePresentation.Slides.FindBySlideID(258)
MsgBox oSl.SlideIndex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM