How to write PowerPoint slide change to a file?

倖福魔咒の 提交于 2020-01-04 05:54:21

问题


I want to write to a file every time a slide is changed (next/back) in PowerPoint.

With presentation.pps I want to write in the file something like:

  1. presentation - slide 1 - 11h04m03s
  2. presentation - slide 2 - 11h04m34s

Does anyone know how to do this?


回答1:


Okay, so here's what you need to do. Note one thing important - a PPS does not include a method to have a macro start upon opening the PPS. If you want that functionality, create an add-in (ppa) instead.

For the PPS, create a module and a class. (If you're not sure how to do this, you may need to study the Object Model more before continuing). The module can be named anything. Name the class "clsWriteToFile". In clsWriteToFile, put the following:

Public WithEvents PPTEvent As Application 'this is at the top of the class

Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
'MsgBox ActivePresentation.Slides.Item(1).SlideNumber
'This is meant to illustrate that it is here you will write what you need to the file,
'like a slide number or time stamp, etc.
End Sub

In the module, put the following:

Public newPPTEvents As New clsWriteToFile
Sub StartLogging()
Set newPPTEvents.PPTEvent = Application
'this would be the location you either create the file or open an existing one.
End Sub

You'll need to write the code to read/write from a file. The FileSystemObject is useful in that regard.

To get this working with a PPS without going into the VBA, you'll have to have a manual trigger on the actual slide. An example would be to add a shape to the first slide, like a rounded rectange. Add it and type "Start Show". Then, add an Action. The action would be on "Mouse_Click"->"Run Macro" and then choose the StartLogging sub routine.

And that's it.

If you are using a PPA instead of a PPS, you could remove the need for the last step by just naming the "StartLogging" routine to "Auto_Open".



来源:https://stackoverflow.com/questions/1880265/how-to-write-powerpoint-slide-change-to-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!