Using excel I need to open PPT and create gif image of a pdf and save it

0 votes

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
Dec 24, 2022 in Others by Kithuzzz
• 38,000 points
470 views

1 answer to this question.

0 votes

It appears happier if you get a reference to the Presentation as an object variable, regardless of whether there is a bug in the OM or not. Although I didn't actually add the PDF ole object and export the slide as a GIF, the rest of it works thanks to Aircode:

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
' I added this
Dim PPTPres As Object

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

' get a reference to the presentation in PPTPres:
Set PPTPres = NewPPT.presentations.Add

' and use PPTPres to refer to the presentation and its
' properties/methods from here on:
PPTPres.Slides.AddSlide 1, PPTPres.SlideMaster.CustomLayouts(1)

    With PPTPres.PageSetup
        .SlideWidth = PDFWidth
        .SlideHeight = PDFHeight
    End With

Set sh = PPTPres.Slides(1).Shapes.AddOLEObject(0, 0, PDFWidth, PDFHeight, , OriginalPath)

Call PPTPres.Slides(1).Export(NewPath, "GIF")

End Sub
answered Dec 24, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How can I store the data of an open excel workbook in a collection using BluePrism?

To do what you want is like ...READ MORE

answered Nov 24, 2022 in Others by narikkadan
• 63,600 points
1,363 views
0 votes
1 answer

Is there a way to test a formula result in excel and type it only once, all within one cell and not using a user defined function?

Use the Let function: =LET(Value,A1+B2+C4+G3+B4,IF(Value>10,"No",Value)) I hope this helps ...READ MORE

answered Jan 9, 2023 in Others by narikkadan
• 63,600 points
665 views
0 votes
1 answer

Is it possible to create a universal hyperlink in excel for windows and mac without programming

You may learn whether it runs on ...READ MORE

answered Mar 28, 2023 in Others by Kithuzzz
• 38,000 points
873 views
0 votes
1 answer

How to modify Powerpoint Chart ChartData by Excel VBA

Example: Code: Set pptApp = GetObject(, "PowerPoint.Application") Set pptPres = ...READ MORE

answered Oct 16, 2022 in Others by narikkadan
• 63,600 points
3,006 views
0 votes
1 answer

Changing code to adjust number of charts on each powerpoint slide VBA

Try this: Option Explicit Sub CopyChartsToPowerPoint() ...READ MORE

answered Jan 23, 2023 in Others by narikkadan
• 63,600 points
526 views
0 votes
1 answer

TextEffect to TextFrame Adjustment (Mismatch)

Delete the original shape and then replace, ...READ MORE

answered Mar 25, 2023 in Others by narikkadan
• 63,600 points
621 views
0 votes
1 answer

VBA Check to see if file is open before reopening a second file

You could replace the line: Set pre = ...READ MORE

answered Apr 4, 2023 in Others by Kithuzzz
• 38,000 points
877 views
0 votes
1 answer

In a excel formula I need to create a list of names on one sheet based upon criteria/data of another sheet

The final formula is: =IF(ROWS($H$3:H3)<=$I$1,INDEX(Personnel! ...READ MORE

answered Nov 25, 2022 in Others by narikkadan
• 63,600 points
1,103 views
0 votes
1 answer

I want to make Excel read a value in Calc and copy it to my sheet in Excel

Here is the sample code that will allow ...READ MORE

answered Oct 27, 2022 in Others by narikkadan
• 63,600 points
515 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP