recursive code for running sub-routine

G

Geoff Cox

Hello,

I once asked here whether it was possible to run a sub-routine on lots
of files in a series of sub-folders, using a recursive approach.

At the time I didn't succeed but with a pointer from Jonathan West in
the vba ng I have got something to work.

Just thought this might be of use to someone!

The code runs through a series ppt files in a set of sub-folders and
checks to see if the last slide does not have an action button on it.

That is by the way but it does show how to run a sub-routine on lots
of files in a series of sub-folders.

Cheers,

Geoff

Sub search_subfolders()

Set fs = Application.FileSearch
With fs
.LookIn = "C:\a-temp"
.SearchSubFolders = True
.FileName = "*.ppt"
If .Execute() > 0 Then

For i = 1 To .FoundFiles.Count
check_for_button_lastslide (.FoundFiles(i))
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub

Sub check_for_button_lastslide(strMyFile As String)

Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)

With oPresentation


Dim oSh As shape
Dim bFoundButton As Boolean
Dim bFoundRectangle As Boolean

bFoundButton = False ' to start

With ActivePresentation.Slides(ActivePresentation.Slides.Count)

If .Shapes.Count > 0 Then

For Each oSh In _
ActivePresentation.Slides(ActivePresentation.Slides.Count) _
.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 130 Then
bFoundButton = True
End If
End If
Next


If Not bFoundButton Then
MsgBox "No button on last slide of " & strMyFile
End If

Else
MsgBox "No shape on this last slide in " & strMyFile
End If

End With

oPresentation.Close

End With

Set oSh = Nothing
Set oPresentation = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top