Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / August 2006

Tip: Looking for answers? Try searching our database.

recursive code for running sub-routine

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Geoff Cox - 10 Aug 2006 20:05 GMT
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
Bill Dilworth - 11 Aug 2006 01:18 GMT
**Batch: Do something to every file in a folder
http://www.pptfaq.com/FAQ00536.htm

Last update 25 April, 2006

Signature

Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@     Please read the PowerPoint FAQ pages.
yahoo.             They answer most of our questions.
com                 www.pptfaq.com
.

> Hello,
>
[quoted text clipped - 80 lines]
>
> End Sub
Geoff Cox - 11 Aug 2006 07:40 GMT
>**Batch: Do something to every file in a folder
>http://www.pptfaq.com/FAQ00536.htm

Thanks Bill - that I did not know.

Cheers

Geoff

>Last update 25 April, 2006
Geoff Cox - 11 Aug 2006 09:06 GMT
>**Batch: Do something to every file in a folder
>http://www.pptfaq.com/FAQ00536.htm
>
>Last update 25 April, 2006

Bill,

Looking at the above - it only works on the files in a folder - my
code works on all files in the folder and any sub-folders.

Cheers

Geoff
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.