Dear GaSouGuy13,
The error youre seeing (Method 'AddOLEObject' of object 'Shapes' failed) is commonly caused by issues in file paths, missing or misplaced quotes,
or incomplete variables in VBA. Let's correct its
Corrected Code
Ensure all file paths are properly formatted.
Add missing quotes and correct any syntax errors.
Check the syntax and parameters for AddOLEObject.
Dim fpath As String
Dim f1 As String, f2 As String, f3 As String, f4 As String
Dim dtvr As String
Dim ppt_app As Object, mypres As Object
Dim n As Integer
Dim myslides As Object
' Define the folder path and file names
fpath = "folders\"
f1 = "docname1.pdf"
f2 = "docname2.xlsx"
f3 = "docname3.xlsx"
f4 = "docname4.docx"
' Define the date variable
dtvr = cyear & cmonth & cday
' Set the PowerPoint application and presentation
Set ppt_app = CreateObject("PowerPoint.Application")
Set mypres = ppt_app.Presentations("string" & dtvr & ".pptx")
' Get the last slide
n = mypres.Slides.Count - 1
Set myslides = mypres.Slides(n)
' Embed the PDF file as an OLE object on the slide
myslides.Shapes.AddOLEObject _
FileName:=fpath & f1, _
Link:=msoFalse, _
DisplayAsIcon:=msoTrue, _
IconLabel:=f1, _
IconIndex:=5, _
IconFileName:="C:\Windows\Installer\{90160000-000F-0000-1000-0000000FF1CE}\xlicons.exe"
Bookmarks