none
PowerPoint insert image inside a table cell RRS feed

  • Question

  • Hello,

    I'm developing a small application in Microsoft Access 2007, that opens a powerpoint file and then inserts image and text in it.

    My problem is that when trying to insert a image inside a table cell, i just can't find the method to do it, i'm trying to use paste especial, but that gives run-time '13' type mismatch

    pptobj.ActivePresentation.Slides(1).Shapes("TableData").Table.Cell(1, 1).Shape.TextFrame.TextRange.PasteSpecial(ppPasteJPG = "c:\image.jpg")

    Any ideas?

    Thanks

    Wednesday, March 27, 2013 12:36 PM

Answers

  • Hi Nelson,

    I think we can add a table in a word document and add the image in a cell in the table. After that, insert the word into the PowerPoint.

    Word macro:

    Sub Test()
    Dim tbl As Table
    Dim rng As Range
    Set rng = ThisDocument.Range(0)
    Set tbl = ThisDocument.Tables.Add(rng, 3, 3)
    Dim cel As Cell
    Set cel = tbl.Cell(3, 1)
    cel.Range.InlineShapes.AddPicture "C:\Users\v-yoyj\Pictures\flower65.jpg", False, True
    
    With tbl
    With .Borders(wdBorderLeft)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderRight)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderTop)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderBottom)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderHorizontal)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth025pt
      End With
      With .Borders(wdBorderVertical)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth100pt
      End With
    End With
    
    
    End Sub
    

    Macro to insert the word:

    ActivePresentation.Slides(1).Shapes.AddOLEObject Left:=100, Top:=100, _
        Width:=500, Height:=300, _
        FileName:="C:\the path of the test document\test.doc", Link:=msoFalse

    We can do word automation in PowerPoint so it can be done in single PowerPoint module.

    Good day.


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 28, 2013 1:15 PM
    Moderator

All replies

  • ok, i got this kind of working,

        pptobj.ActivePresentation.Slides(1).Shapes("TableData").Table.Cell(1, 1).Shape.Fill.UserPicture ("c:\image.jpg"), but the problem is that this method strechs the picture, and i can't have that.

    i have found another method that keeps the aspect ratio ok, but puts the picture over the text, and i need it to be in line with text, when it's big to push the text down.

        pptobj.ActivePresentation.Slides(1).Shapes.AddPicture(FileName:="c:\image.jpg", linktofile:=mostrue, savewithdocument:=msoTrue, Left:=52, Top:=115).Select

        With pptobj.ActivePresentation.Slides(1).Shapes("Picture 3")
            .LockAspectRatio = msoTrue
            .Width = 85
            .Left = 52
            .Top = 100
            .Cut
        End With

    Any ideias?

    Thanks again :-)

    Wednesday, March 27, 2013 3:00 PM
  • Hi Nelson,

    I think we can add a table in a word document and add the image in a cell in the table. After that, insert the word into the PowerPoint.

    Word macro:

    Sub Test()
    Dim tbl As Table
    Dim rng As Range
    Set rng = ThisDocument.Range(0)
    Set tbl = ThisDocument.Tables.Add(rng, 3, 3)
    Dim cel As Cell
    Set cel = tbl.Cell(3, 1)
    cel.Range.InlineShapes.AddPicture "C:\Users\v-yoyj\Pictures\flower65.jpg", False, True
    
    With tbl
    With .Borders(wdBorderLeft)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderRight)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderTop)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderBottom)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
      End With
      With .Borders(wdBorderHorizontal)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth025pt
      End With
      With .Borders(wdBorderVertical)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth100pt
      End With
    End With
    
    
    End Sub
    

    Macro to insert the word:

    ActivePresentation.Slides(1).Shapes.AddOLEObject Left:=100, Top:=100, _
        Width:=500, Height:=300, _
        FileName:="C:\the path of the test document\test.doc", Link:=msoFalse

    We can do word automation in PowerPoint so it can be done in single PowerPoint module.

    Good day.


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 28, 2013 1:15 PM
    Moderator
  • Hi Nelson,

    How is it going with the problem?

    Good day.


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 1, 2013 4:47 AM
    Moderator