Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch processing in powerpoint

Status
Not open for further replies.

zolero

Programmer
Aug 29, 2010
2
SE
Hi all!

This is my first post in this forum and I was hoping that you could help me with a problem that I am having.
I have to save about 200 powerpoint files (.ppt) as jpg and I figured i could write a macro for this. So the solution I have come up with is this.

An excel sheet with all the filenames and path. My macro loops through the filenames, opens the files in powerpoint and then saves them as jpg. I have managed to do everything except för the saving part. I have written the following code:

Sub LoopSelection()
Worksheets("Sheet1").Select
c = ActiveWindow.RangeSelection.Address
Dim ppt As Object
Dim varde As String
Dim dir As String
Dim filename As String

Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = True
dir = Worksheets("Sheet1").Range("A1").Value

For Each r In Worksheets("Sheet1").Range(c).Cells

filename = dir + r.Value
ppt.Presentations.Open (filename)
ppt.Presentation.SaveAs "001", ppSaveAsJPG
ppt.Presentation.Close

Next r
End Sub

And when i run the program I manage to start powerpoint with the specified file but it is unable to call the SaveAs subroutine. I get error number 438. I don't have a clue how to solve this problem and look forward to your suggestions.

Cheers
zolero :)
 
>ppt.Presentation.SaveAs "001", ppSaveAsJPG

I am not a PP person but;

Rem out the line and replace with;
MsgBox filename
just to check that each presentation can be retrieved without error. If that is ok...

Just now it appears that you are trying to save all the files to a single file named "001". I think you are going to have to replace that with a full path and unique filename which ends with no extension or '.jpg'.

Alternatively (assuming a quirk in ppSaveAsJPG) have you tried saving as other formats?
 
Thanks for the tip. I managed to solve the problem though with some extensive reading on microsoft website. So following works like a charm.

Sub LoopSelection()
Worksheets("Sheet1").Select
c = ActiveWindow.RangeSelection.Address
Dim ppt As Object
Dim varde As String
Dim kat As String
Dim filename As String

Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = True
kat = Worksheets("Sheet1").Range("A1").Value

For Each r In Worksheets("Sheet1").Range(c).Cells

filename = kat + r.Value
ppt.Presentations.Open (filename)
ppt.ActivePresentation.SaveAs filename, ppSaveAsJPG


Next r
End Sub

Cheers
Zol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top