Need to save pen tool drawigns in powerpoint before exiting

83 views Asked by At

I have working macro for switching mouse cursor to pen tool and back to cursor. Now the problem is, that after I have done my drawing with pen tool, I use macro to export that page to .pdf and after that quit slideshow with

ActivePresentation.SlideShowWindow.View.Exit

and after pressing macro button PP ask if I want to Keep or Discard my drawing. After pressing Keep, slideshow shut down, new pdf file is created, but drawing doesn't get to in. If I export that page again, then it shows up. So it seems it creates .pdf first and after that saves the drwaing.

So is there a way to save drawing before exiting slideshow? It is fine if drawing is not there after leaving slideshow, but I want it to be in .pdf after first click.

Current macro for pdf export is

Sub convert_to_PDF()

Dim timestamp As Date
Dim PR As PrintRanges
Dim lngLast As Long
Dim lngFirst As Long
Dim savePath As String
Dim PrintPDF As Integer
Dim name As String
Dim originalHides() As Long
Dim slidesToPrint() As Variant
Dim i As Variant

timestamp = Now()
With ActivePresentation
    name = .Slides(2).Shapes("TextBox1").OLEFormat.object.Text
    savePath = "C:\Powerpoint\" & Format(timestamp, "yyyymmdd-hhnn") & " - " & name & ".pdf"
    lngLast = .Slides.Count
    .PrintOptions.Ranges.ClearAll
    
    slidesToPrint = Array(2, lngLast)
    
    ReDim originalHides(1 To lngLast)
    For i = 1 To lngLast
      originalHides(i) = .Slides(i).SlideShowTransition.Hidden
      .Slides(i).SlideShowTransition.Hidden = -1
    Next
    For Each i In slidesToPrint()
      .Slides(i).SlideShowTransition.Hidden = 0
    Next
    .ExportAsFixedFormat _
        Path:=savePath, _
        FixedFormatType:=ppFixedFormatTypePDF, _
        Intent:=ppFixedFormatIntentScreen, _
        FrameSlides:=msoTrue
    For i = 1 To lngLast
      .Slides(i).SlideShowTransition.Hidden = originalHides(i)
    Next
EraseInkOnSlide ActivePresentation.Slides(lngLast)
End With
End Sub
0

There are 0 answers