PDA

View Full Version : Macro to Save PPS files as PPT



javaman12
03-08-2013, 12:46 PM
Hello,

I have many PPS files stored in a folder that I need converted into PPT. I've tried piecing together a macro based on what I've found online, but I can't get it to work. Here's what I've come up with so far, but it results in an Type Mismatch error:


Sub LoopDirectory()
Dim vDirectory As String
Dim oPres As Presentations

vDirectory = "C:\test\"

vFile = Dir(vDirectory & "*.*")

Do While vFile <> ""
Set oPres = Presentations.Open(FileName:=vDirectory & vFile)
ActivePresentation.SaveAs FileName:=vDirectory & vFile, FileFormat:=ppSaveAsDefault
ActivePresentation.Close
vFile = Dir

Loop
End Sub



Can anyone help with this?

John Wilson
03-09-2013, 07:25 AM
You have declared opres as "a" Presentations.

Presentations is only applicable to a collection. You should declare it as a Presentation (no "s")

If you are ONLY looking for pps files

vFile = Dir(vDirectory & "*.pps")

See If this works

Sub saveme()
Dim vDirectory As String
Dim oPres As Presentation
Dim vFile As String
vDirectory = "C:\test\"

vFile = Dir(vDirectory & "*.pps")

Do While vFile <> ""
Set oPres = Presentations.Open(vDirectory & vFile)
oPres.SaveAs FileName:=vDirectory & Left(oPres.Name, Len(oPres.Name) - 4) & ".ppt"
oPres.Close
vFile = Dir

Loop
End Sub

javaman12
03-11-2013, 06:16 AM
That looks like it did the trick! Thanks!