D
Dave Jenkins
I'm trying to save selected slides using code that must run on PPT 2007 and
PPT 2003. Here's a copy of the pertinent code that I've been dinking with:
' Create a FileDialog object as a File SaveAs dialog box.
' fd.SelectedItems(1) will be name of file to save as
Set fd = Application.FileDialog(msoFileDialogSaveAs)
'Use a With...End With block to reference the FileDialog object.
With fd
If val(Application.Version) < 12 Then
.InitialFileName = ActivePresentation.Path & "\slides.ppt"
Else
.InitialFileName = ActivePresentation.Path & "\slides.pptx"
End If
.Title = "Slide Subset Save"
For i = 1 To .Filters.Count
If val(Application.Version) < 12 Then
If .Filters(i).Description = "PowerPoint 97-2003 Presentation"
Then
.FilterIndex = i
Exit For
End If
Else
If .Filters(i).Description = "PowerPoint Presentation" Then
.FilterIndex = i
Exit For
End If
End If
Next i
'Use the Show method to display the File Picker dialog box and return
the user's action.
'The user pressed the button.
If .Show = -1 Then ' save
If val(Application.Version) < 12 Then
ActiveWindow.Selection.SlideRange.Export fd.SelectedItems(1),
"PPT"
Else
===> ActiveWindow.Selection.SlideRange.Export fd.SelectedItems(1), "PPTX"
End If
End If
End With
Set fd = Nothing
Exit Sub
If the indicated statement reads "PPTX" I get a runtime error saying no
filter exists for "PPTX." If use "PPT" then I get a filename of the form
"filename.pptx.ppt". I have jimmy everything so that it specifies "PPT" then
I can get a file of the form "filelname.ppt"
BTW, this routine wants to create a new presentation using slides selected
in the thumbnail pane. It only seems to export one slide, however. Can I
even do what I want?
And lastly, PowerPoint crashes everytime I exit this sub, regardless of the
number of slides selected - what's up with that?
Thanks.
PPT 2003. Here's a copy of the pertinent code that I've been dinking with:
' Create a FileDialog object as a File SaveAs dialog box.
' fd.SelectedItems(1) will be name of file to save as
Set fd = Application.FileDialog(msoFileDialogSaveAs)
'Use a With...End With block to reference the FileDialog object.
With fd
If val(Application.Version) < 12 Then
.InitialFileName = ActivePresentation.Path & "\slides.ppt"
Else
.InitialFileName = ActivePresentation.Path & "\slides.pptx"
End If
.Title = "Slide Subset Save"
For i = 1 To .Filters.Count
If val(Application.Version) < 12 Then
If .Filters(i).Description = "PowerPoint 97-2003 Presentation"
Then
.FilterIndex = i
Exit For
End If
Else
If .Filters(i).Description = "PowerPoint Presentation" Then
.FilterIndex = i
Exit For
End If
End If
Next i
'Use the Show method to display the File Picker dialog box and return
the user's action.
'The user pressed the button.
If .Show = -1 Then ' save
If val(Application.Version) < 12 Then
ActiveWindow.Selection.SlideRange.Export fd.SelectedItems(1),
"PPT"
Else
===> ActiveWindow.Selection.SlideRange.Export fd.SelectedItems(1), "PPTX"
End If
End If
End With
Set fd = Nothing
Exit Sub
If the indicated statement reads "PPTX" I get a runtime error saying no
filter exists for "PPTX." If use "PPT" then I get a filename of the form
"filename.pptx.ppt". I have jimmy everything so that it specifies "PPT" then
I can get a file of the form "filelname.ppt"
BTW, this routine wants to create a new presentation using slides selected
in the thumbnail pane. It only seems to export one slide, however. Can I
even do what I want?
And lastly, PowerPoint crashes everytime I exit this sub, regardless of the
number of slides selected - what's up with that?
Thanks.