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