In article <(E-Mail Removed)>, Geoff Cox wrote:
> On Mon, 12 Jun 2006 09:12:52 +0100, Geoff Cox
> <(E-Mail Removed)> wrote:
Try rewriting MyMacro as a function instead of a sub:
I'm also renaming it to make its use more obvious
Function CountSlides(strMyFile As String) as Long
' Open a presentation named in strMyFile
' Return the number of slides in the presentation
Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)
CountSlides = oPresentation.Slides.Count
oPresentation.Close
End Sub
Now in your main code you can use something like:
' assuming you Dim lTotalSlides as Long:
lTotalSlides = lTotalSlides + CountSlides(strMyFile)
>
> I am trying the following code - it is the sub MyMacro which I need a
> little help with.
>
> I can get the number of slides for each presentation but how do I get
> the total number of slides for all presentations?
>
> I guessing I need something like
>
> slidesPerPresentation = ActivePresentation.Slides.Count
>
> totalSlides = totalSlides + slidesPerPresentaion
>
> but not clear how to do this.
>
> Thanks
>
> Geoff
>
> Sub check_each_slide_for_buttons()
>
> 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"
>
> 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
>
> End Sub
>
> Sub MyMacro(strMyFile As String)
>
> Dim oPresentation As Presentation
> Set oPresentation = Presentations.Open(strMyFile)
>
> With oPresentation
>
> MsgBox = "number of slides = " & ActivePresentation.Slides.Count
>
>
> oPresentation.Close
>
> End With
>
> End Sub
>
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:
www.pptfaq.com
PPTools:
www.pptools.com
================================================