+ Reply to Thread
Results 1 to 2 of 2

Embedding Documents in PowerPoint using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    11-01-2024
    Location
    Florida, USA
    MS-Off Ver
    365
    Posts
    1

    Post Embedding Documents in PowerPoint using VBA

    This is my first post on the excel forum, and I like to think I am good at excel, but this is alluding me. I am trying to automate the metrics I generate, and I've managed to get the excel raw data manipulation down and the excel charts to ppt down, but I want more automation, so I'm trying to added a few embedded files as well.

    fpath = "folders\"
    f1 = "docname1.pdf"
    f2 = "docname2.xlsx"
    f3 = "docname3.xlsx
    f4 = "docname4.docx"
    dtvr= cyear & cmonth & cday
    set mypres = ppt_app.presentations("string" & dtvr & ".pptx"
    n = mypress.slides.count -1
    set myslides = mypress.slides(n)
    myslides.shapes.addoleobject Filename:=fpath & f1, link:=msoFalse, displayasicon:=msoTrue, iconlabel:=f1, iconindex:=5, iconfiliename:="C:\Windows\Installer\{90160000-000F-0000-1000-0000000FF1CE}\xlicons.exe"
    I will probably delete the current icons that are there and replace the iconindex with a 1 assuming it works with bit of code.

    variant of the addoleobject
    set osh = myslides.shapes.addoleobject -then parameters
    I tried to follow the workbooks.worksheets logic and the examples i've found and it looks right, but i get the error: '-214767259 (80004005) Method 'AddOLEObject' of object 'Shapes' failed. Any help to fix my code or simpler method of embedding objects will be greatly appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    440

    Re: Embedding Documents in PowerPoint using VBA

    Dear GaSouGuy13,

    The error you’re 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"
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Mark Thread as Solved...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Separating a documents worksheets into individual documents
    By CWinkler in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-30-2019, 07:22 PM
  2. Excel 2007 VBA code to close powerpoint slide show, but not powerpoint application
    By christopher@groth.cc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-18-2015, 06:39 AM
  3. Documents and Settings All Users Documents - Access is denied
    By peterrc in forum Microsoft Windows Help
    Replies: 8
    Last Post: 01-26-2014, 06:30 AM
  4. convert all 97-2003 excel documents to macro enabled documents on server
    By viperisback in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2013, 09:06 AM
  5. Embedding spreadsheet with full functionallity into Powerpoint
    By Thomasja99 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-23-2009, 07:48 PM
  6. [SOLVED] embedding sound documents in excel
    By Françoise Evans in forum Excel General
    Replies: 1
    Last Post: 05-14-2006, 05:40 AM
  7. excel documents won't open from my documents folder
    By Paul1961 in forum Excel General
    Replies: 2
    Last Post: 01-15-2006, 01:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1