2017-02-27 17 views
0

高校生のためのパワーポイントでバーチャルラボを作りました。スライドには質問があります。彼らはテキストボックスに答えを残すことができます。パワーポイント内の特定のスライドの配列をPDFにエクスポート

最後に、質問があったスライドだけをPDFファイルに保存するマクロを含むボタンを挿入します。他のスライドは教師とは無関係です。

要するに、私は、スライドの選択肢をPDFとして保存できるPowerPointマクロを作成しようとしています。そのスライドの範囲ではなく、スライドの選択。

現在、私は、この持っている:私は(仕事をする)このコードを使用することができるよりもスライドの範囲でそれをしたい場合は、そのは

を働いていないが

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 

このマクロは機能しますが、そのスライドまたは1つの特定のスライドだけを印刷できます。特定のスライドの配列をPDFに印刷したい私はこのトピックに関する関連する質問を見てきましたが、私は非常に関連性の高い例でも私の問題を解決できないほどの大きな騒ぎです。

+0

現在のプレゼンテーションの一時コピーを保存し、Slidesコレクションを後ろにして、条件に合致しないスライドを削除してから結果をPDFに保存します。 –

+0

@SteveRindsbergそれはうまくいくかもしれませんが、スライドの総量は350ですので、非常に面倒です(特に約20名の学生が課題を行うため、すべてが別のファイルになります)。学生は、異なるDNA要素を整理し、正しい順序で配置する必要があります。使用する順序に応じて、単純なIfを使用して別のスライドに送信しますテキストボックス= ...次にスライドを表示...他のすべてのパスは割り当て後に無関係になります。 –

答えて

0

私はそれをしました!私は、エラーのは、どこから来たのか、最後に発見され、今取り組んでマクロ

Private Sub CommandButton4_Click() 
Dim myInput As String 
Dim savePath As String 

'Name of Student 
myInput = ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text 

'Location of saved file 
savePath = ActivePresentation.Path & "\" & myInput & " Antwoorden Virtueel Lab" & ".pdf" 

'Select path student took 
If ActivePresentation.Slides(9).Shapes("TextBox1").OLEFormat.Object.Text = "PRARDT" Then 

'Change view 
ActivePresentation.SlideShowWindow.View.Exit 

'Prevents error 
ActiveWindow.Panes(1).Activate 

'Select specific slides 
ActivePresentation.Slides.Range(Array(9, 11, 15)).Select 

'save selected slides as PDF 
ActivePresentation.ExportAsFixedFormat Path:=savePath, FixedFormatType:=ppFixedFormatTypePDF, RangeType:=ppPrintSelection 

MsgBox "file saved" 

Else 
MsgBox "wont work" 

End If 

End Sub 

今私は、もし9が異なるように、各パスのために保存する必要がスライドする選択でしょうがあります。

関連する問題