views:

89

answers:

1

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  A: 

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".

Otaku
aF, did this work for you?
Otaku
tks m8 :)very good answer!
aF