Я пытаюсь вызвать подфункцию, но не удается с ошибкой:
Тип пользователя, не определенный в методе saveas в этой строке. Возможно, презентация не обрабатывается в vba
Ошибка находится в первой строке SavePDFAsPng
:
Dim oPres As Presentation
Вот весь макрос:
Sub Button1_Click()
Call SavePDFAsPng("C:\Users\gfas1\Desktop\ahm.pdf", "C:\Users\gfas1\Desktop\MyTest.PNG")
End Sub
Sub SavePDFAsPng(sPathToPDF As String, sPathToPNG As String)
Dim oPres As Presentation
Dim oSh As Shape
' Height/Width are hardcoded here
' You could get trickier and bring the PDF into any presentation
' once to get its proportions, delete it, set the slide size to the same
' proportions, then re-insert the PDF
Dim sngWidth As Single
Dim sngHeight As Single
sngWidth = 612
sngHeight = 792
Set oPres = Presentations.Add
With oPres
With .PageSetup ' set it to 8.5x11
.SlideHeight = sngHeight ' 11in * 72 points per inch
.SlideWidth = sngWidth
End With
.Slides.AddSlide 1, .SlideMaster.CustomLayouts(1)
With .Slides(1)
Set oSh = .Shapes.AddOLEObject(0, 0, sngWidth, sngHeight, , sPathToPDF)
Call .Export(sPathToPNG, "PNG")
End With
.Saved = True
.Close
End With
End Sub