我可以添加一个范围,但无法添加多个范围并在变量中确定它:
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/