Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Link excel .jpg files to Powerpoint (Excel/PPT xp)

    I have an Excel sheet with 40 files names in column A. Cell A1 is C:mainimages4279.jpg, Cell A2 is C:mainimages37.jpg, Cell A3 etc. down to A40.

    I want to write a macro to put these logos in 40 matching powerpoint files. For instance, the 4279.jpg goes 1" down and 2" to the left in 4279.ppt. The 37.jpg logo will go in the same position in the 37.ppt file. Is this possible to do this programatically? Can someone help me with the code? Thank you for the help.

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Link excel .jpg files to Powerpoint (Excel/PPT xp)

    Put them where? on the slide master? In any case, you use the AddPicture method of the Shapes collection. If you record a macro in PowerPoint that pastes a graphic from a file, you will see more information. Let me know if you need more information. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Link excel .jpg files to Powerpoint (Excel/PPT xp)

    Attached is a sample workbook that does what you want and more. The worksheet columns are as follows:
    A -- Presentation
    B -- Picture
    C -- Slide number on which to insert the picture (M for master)
    D -- Distance to the left edge of the picture in inches
    E -- Distance to the top edge in inches
    F -- Yes or No, indicating whether to wash-out the picture or not.

    Here is the macro code. Note, I notice that you usually have all of you applications open. This example assumes that the presentations are not open. It opens an invisible copy of Powerpoint, edits and saves the presentations, without any visible indications. Have fun. --Sam
    <pre>Option Explicit

    Sub PastePics()
    ' You must add a reference to PowerPoint Object Library
    Dim i As Integer, sngL As Single, sngT As Single
    Dim ws As Worksheet
    Dim ppApp As New PowerPoint.Application
    Dim ppShapes As PowerPoint.Shapes
    Set ws = Worksheets("Pics")
    For i = 2 To ws.UsedRange.Rows.Count
    With ppApp.Presentations.Open( _
    Filename:=ActiveWorkbook.Path & "" & ws.Cells(i, 1), _
    WithWindow:=False)
    If ws.Cells(i, 3) = "M" Then
    Set ppShapes = .SlideMaster.Shapes
    Else
    Set ppShapes = .Slides(ws.Cells(i, 3).Value).Shapes
    End If
    sngL = Application.InchesToPoints(ws.Cells(i, 4))
    sngT = Application.InchesToPoints(ws.Cells(i, 5))
    With ppShapes.AddPicture( _
    Filename:=ActiveWorkbook.Path & "" & ws.Cells(i, 2), _
    LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
    Left:=sngL, Top:=sngT)
    If ws.Cells(i, 6) = "Yes" Then _
    .PictureFormat.ColorType = msoPictureWatermark
    End With
    .Save
    .Close
    End With
    Next i
    Set ppShapes = Nothing
    Set ppApp = Nothing
    End Sub</pre>

    Attached Files Attached Files
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Link excel .jpg files to Powerpoint (Excel/PPT xp)

    Thank you very much.

    Here is what i've done. I want to put the picture that i have in column B in the test.ppt (template) and then do a save as and save the file as another name like main1.ppt.

    Then open the test.ppt again and put the next picture in and do a save as another file name, like main2.ppt. and so on.

    Can i do it with your code this way? thank you
    Attached Files Attached Files

  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Link excel .jpg files to Powerpoint (Excel/PPT xp)

    Yes, just use powerpoint's SaveAs method instead of the Save that I used.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

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