将PowerPoint幻灯片导出为幻灯片标题

时间:2018-09-17 05:44:55

标签: vba powerpoint

我有兴趣将pptx中的每张幻灯片导出为以文档标题(即幻灯片标题字段中的文本)命名的PDF格式

我从这里运行良好的脚本开始:

Sub ExportHTML()
 Dim path As String
    path = GetSetting("FPPT", "Export", "Default Path")

    With Application.FileDialog(msoFileDialogFolderPicker)
        .InitialFileName = path
        .AllowMultiSelect = False
        .Title = "Select destination folder"
        .Show
        If .SelectedItems.Count = 1 Then
            path = .SelectedItems(1)
            Save_PowerPoint_Slide_as_Images (path)
            MsgBox "Saving slides to " + path
        Else
            MsgBox "Nothing was saved"
        End If
    End With

    If path <> "" Then
        'Open path For Output As #n
        SaveSetting "FPPT", "Export", "Default Path", path
    End If
End Sub
Sub Save_PowerPoint_Slide_as_Images(path As String)
    Dim sImagePath As String
    Dim sImageName As String
    Dim sPrefix As String
    Dim oSlide As Slide '* Slide Object
    Dim lScaleWidth As Long '* Scale Width
    Dim lScaleHeight As Long '* Scale Height
    On Error GoTo Err_ImageSave

    sImagePath = path
    sPrefix = Split(ActivePresentation.Name, ".")(0)
    For Each oSlide In ActivePresentation.Slides
    sImageName = oSlide.Shapes.Title.TextFrame.TextRange.Text & ".png"
    oSlide.Export sImagePath & "\" & sImageName, "PNG"
    Next oSlide

Err_ImageSave:
    If Err <> 0 Then
    MsgBox Err.Description
    End If
End Sub
Sub slideid()
ActivePresentation.Slides(1).slideid
End Sub

但是,如果我将扩展名更改为.pdf,它似乎无法正常工作。有什么方法可以用pdf实现吗?

0 个答案:

没有答案