Geoff
You need to declare a variable that has global scope (read up on Scope
in Help)
Put at the top of the module before any Sub routines the following
Public lSlideTotal as Long
Then modify MyMacro to add the counter
'Next line adds the running total. Starts at 0 on first pressie
lSlideCount = lSlideCount + activepresentation.slides.count
Brian,
I seme to have used your suggests correctly in that the code works but
if I run it successively the total keeps adding to itself - where do I
prevent this?
Thanks
Geoff
Public lSlideCount As Long
Sub count_slides()
Dim rayFileList() As String
Dim FolderPath As String
Dim FileSpec
Dim strTemp As String
Dim x As Long
FolderPath = "c:\test\activities\" ' Note: MUST end in \
FileSpec = "*.ppt"
' Fill the array with files that meet the spec above
ReDim rayFileList(1 To 1) As String
strTemp = Dir$(FolderPath & FileSpec)
While strTemp <> ""
rayFileList(UBound(rayFileList)) = FolderPath & strTemp
ReDim Preserve rayFileList(1 To UBound(rayFileList) + 1) As
String
strTemp = Dir
Wend
If UBound(rayFileList) > 1 Then
For x = 1 To UBound(rayFileList) - 1
Call MyMacro(rayFileList(x))
Next x
End If
MsgBox "total = " & lSlideCount
End Sub
Sub MyMacro(strMyFile As String)
Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)
With oPresentation
lSlideCount = lSlideCount + ActivePresentation.Slides.Count
oPresentation.Close
End With
End Sub