【发布时间】:2017-07-18 11:21:12
【问题描述】:
我在 PowerPoint 中为高中生制作了一个虚拟实验室,偶尔会有一张幻灯片向他们提问。他们可以将答案留在文本框中。
最后,我想插入一个包含宏的按钮,该宏将仅将存在问题的幻灯片保存到 PDF 文件中。其他幻灯片与老师无关。
简而言之:我正在尝试制作一个 PowerPoint 宏,我可以在其中将选择的幻灯片另存为 PDF。它不是一系列幻灯片,而是一系列幻灯片。
目前我有这个:
Private Sub CommandButton2_Click()
Dim mySlides As Variant
Dim PR As PrintRange
Dim savePath As String
Dim myInput As String
'Add the name of the student in the file name
myInput = ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text
'Location of saved file
savePath = ActivePresentation.Path & "\" & myInput & " Antwoorden Virtueel Lab" & ".pdf"
If ActivePresentation.Slides(9).Shapes("TextBox1").OLEFormat.Object.Text = "PRARDT" Then
mySlides = Array(9, 11, 15)
Set PR = ActivePresentation.Slides.Range(mySlides)
ActivePresentation.ExportAsFixedFormat _
Path:=savePath, _
FixedFormatType:=ppFixedFormatTypePDF, _
PrintRange:=PR, _
Intent:=ppFixedFormatIntentScreen, _
FrameSlides:=msoTrue, _
RangeType:=ppPrintSlideRange
Else: MsgBox "Does not work"
End If
End Sub
但它不起作用
如果我想使用一系列幻灯片而不是我可以使用此代码(确实有效):
Private Sub CommandButton3_Click()
'This function saves the last slide as a PDF file with a time stamp and the users name who completed the induction.
Dim PR As PrintRange
Dim savePath As String
Dim myInput As String
myInput = ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text
'Location of saved file
savePath = ActivePresentation.Path & "\" & myInput & " Antwoorden Virtueel Lab" & ".pdf"
If ActivePresentation.Slides(9).Shapes("TextBox1").OLEFormat.Object.Text = "PRARDT" Then
With ActivePresentation.PrintOptions
.Ranges.ClearAll ' always do this
Set PR = .Ranges.Add(9, 21)
End With
ActivePresentation.ExportAsFixedFormat _
Path:=savePath, _
FixedFormatType:=ppFixedFormatTypePDF, _
PrintRange:=PR, _
Intent:=ppFixedFormatIntentScreen, _
FrameSlides:=msoTrue, _
RangeType:=ppPrintSlideRange
Else
MsgBox "something went wrong"
End If
End Sub
这个宏确实有效,但我只能用它打印一系列幻灯片或一张特定的幻灯片。我想将一组特定幻灯片打印到 PDF。我已经查看了有关此主题的相关问题,但是我是一个大菜鸟,即使使用它们密切相关的示例,我也无法解决我的问题。
【问题讨论】:
-
一种简单的方法是保存当前演示文稿的临时副本,向后浏览幻灯片集合,删除任何不符合条件的幻灯片,然后将结果保存为 PDF。跨度>
-
@SteveRindsberg 这可以工作,但是幻灯片的总数是 350,所以这将非常乏味(特别是因为大约 20 名学生做作业,因此都制作了不同的文件。幻灯片,因为学生可以选择 10 条不同的路径,这取决于他们在作业中所做的事情。学生必须组织不同的 DNA 元素并按正确的顺序排列它们。根据他们使用的顺序,他们被送到使用简单 If textbox = ... then view slide ... 所有其他路径在分配后变得无关紧要。
标签: vba pdf powerpoint