PDA

View Full Version : Filesearch in 2007



balumail75
04-12-2010, 10:38 AM
Hi all,

Please help me for the below code. I used in ppt 2000. But it's not working in 2007. To convert ppt to jpg. filesearch is not working.


Sub Tojpg()

Dim oApp As Object
Dim ofolder
Dim rpath As String

Dim i As Integer
Dim pname As Variant
Dim pptfile As Variant
Dim fname As Variant
Dim flname As Variant
Dim fpname As Variant

Set oApp = CreateObject("Shell.Application")
'Browse to the folder
Set ofolder = oApp.BrowseForFolder(0, "Select folder", 512)
If ofolder Is Nothing Then
MsgBox "Good-bye! Better Try Next Time!"
Exit Sub
End If
rpath = ofolder.self.path

With Application.FileSearch
.FileName = "*.pptx"
.LookIn = rpath
.SearchSubFolders = True
.Execute

For i = 1 To .FoundFiles.Count
pptfile = .FoundFiles(i)
Application.Presentations.Open pptfile


fpname = ActivePresentation.path
fname = ActivePresentation.Name
flname = Left(fname, 10)
Application.ActivePresentation.Slides(1).Export fpname & "\" & flname & ".jpg", "JPG"
Application.ActivePresentation.Close
'MsgBox .FoundFiles(i) & "converted to jpg"
Next i
End With
End Sub

Thanks in advance......

mdmackillop
04-12-2010, 02:29 PM
FileSearch has been discontinued in 2007. Use Dir to loop through files in the folder.