Let me first describe the structure I'm creating. I have a folder where 50–100.pdf files are added every day. To identify the work location and employee who completed each.pdf, it must be scanned again and saved with a new file name. For tracking purposes, the file must subsequently be linked to an object in an excel spreadsheet. No.pdf may be opened from within Excel VBA due to programming/security restrictions at work. As a result, there is no automation in the process and each file must be opened in Adobe, inspected, resaved, and then each item produced in the spreadsheet must be individually hyperlinked. The user will be able to review each.gif as a picture in an excel userform once the userform iterates through the.pdf folder and saves a.gif image of each.pdf file. After saving, VBA will rename the file, create the object in the spreadsheet, and attach the hyperlink. The code I have for opening a new PPT, adding a slide, adding the.pdf, and then saving it again as a.gif is listed below. On the "pagesetup.slidewidth," I keep getting a "Run time Error 438, Object does not support this property or function." Since I haven't used PPT in years, I'm baffled as to why Excel won't accept this syntac.
Option Explicit
Sub ConvertPDFtoGIF()
Dim OriginalPath As String
Dim NewPath As String
Dim NewPPT As Object
Dim PDFWidth As Single
Dim PDFHeight As Single
Dim sh As Shape
OriginalPath = "C:\Users\hareb\Desktop\Work Tracker\Test\3763A1010100003112022 - Copy (2).pdf"
NewPath = "C:\Users\hareb\Desktop\Work Tracker\Test\Test\TestGIF.GIF"
PDFWidth = 8.5
PDFHeight = 11
Set NewPPT = CreateObject("Powerpoint.application")
NewPPT.Visible = True
NewPPT.Presentations.Add
With NewPPT.PageSetup
.SlideWidth = PDFWidth
.SlideHeight = PDFHeight
End With
NewPPT.Slides.addslide 1, NewPPT.slidemaster.customlayouts(1)
Set sh = NewPPT.Slides(1).Shapes.AddOLEObject(0, 0, PDFWidth, PDFHeight, , OriginalPath)
Call NewPPT.Slides(1).Export(NewPath, "GIF")
End Sub