vba - 在 PrintOptions 下添加范围并在变量中确定它

标签 vba powerpoint

我可以添加一个范围,但无法添加多个范围并在变量中确定它:

Set PR = ActivePresentation.PrintOptions.Ranges.Add(1, 1)

是否可以在上面添加更多范围?

我尝试了以下方法,但无法将其设置为等于 PR

With ActivePresentation
    With .PrintOptions
    .RangeType = ppPrintSlideRange
            With .Ranges
            .ClearAll
            .Add 1, 1
            .Add 3, 3
            End With
    End With
    .PrintOut
End With

是否可以在变量下确定上述范围?

谢谢。

最佳答案

ActivePresentation.PrintOptions.Ranges.Add添加一个范围并返回 PrintRange目的。它不能容纳多个范围,因为它代表单个范围。如果您有多个范围,那么您就有多个 PrintRange 对象,因此您可以访问它们并使用 PrintRanges收藏。

PrintRanges object (PowerPoint)

A collection of all the PrintRange objects in the specified presentation. Each PrintRange object represents a range of consecutive slides or pages to be printed.

Example Use the Ranges property to return the PrintRanges collection.

因此,当您添加多个范围时:

With ActivePresentation
    With .PrintOptions
        .RangeType = ppPrintSlideRange
        With .Ranges
            .ClearAll
            .Add 1, 1
            .Add 3, 3
        End With
    End With
End With

然后您就拥有了 ActivePresentation.PrintOptions.Ranges 的所有范围。收藏。

For Each Range In ActivePresentation.PrintOptions.Ranges
    Debug.Print TypeName(Range)
Next Range

更新

如果你想ExportAsFixedFormat要导出特定幻灯片,您可以选择要导出的幻灯片并使用 ppPrintSelection 作为 RangeType 参数:

' Select slides 1 and 3
ActivePresentation.Slides.Range(Array(1, 3)).Select

' Export PDF with selected slides
ActivePresentation.ExportAsFixedFormat _
    Path:=savePath, _
    FixedFormatType:=ppFixedFormatTypePDF, _
    RangeType:=ppPrintSelection

关于vba - 在 PrintOptions 下添加范围并在变量中确定它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55867361/

相关文章:

c# - 使用c#替换power point中的图像

vba - excel vba从selection.address获取行、单元格值

excel - .csv 的 ADODB 连接字符串

excel - VBA Excel-如何使用 MS Excel 关闭中的取消按钮?

excel - 如何跨工作簿 Excel 进行多个 Vlookup

vb.net - 在 Vb.net 中以编程方式处理 PowerPoint Presenter View 对象事件

excel - 将全名拆分为姓氏,如果姓氏有多个部分(即van,de),则为firstname

vba - 将图表从 Excel 粘贴到特定布局中的特定占位符。简报 2010

iphone - 如何在 iPhone 或 iPad 中从 ppt 文件中的幻灯片中获取图像?

vba - 无法迭代 CustomerData 集合(无效过程调用错误)