Anyone know the syntax for AddPicture to Powerpoint in VB Script?

Discussion in 'Scripting' started by Robert, Dec 18, 2005.

  1. Robert

    Robert Guest

    I'm creating a script to create a powerpoint based on a tab-delimited file
    and pictures all in the same directory. I've been able to do this in VBA but
    haven't figured out the right syntax in VB Script.

    THIS WORKS IN VBA
    With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutTextAndObject)With
    ..Shapes.AddPicture(FileName:="C:\temp\RESI_BBE\24121779.jpg", _
    LinkToFile:=False, SaveWithDocument:=True, _
    Left:=168, Top:=142, Width:=384, Height:=255)
    End With
    End With

    THE CODE BELOW WORKS UNTIL I GET TO "ADDPICTURE" -
    '=====================================================
    ' Create Powerpoint Slides
    '=====================================================
    Do Until objRecordset.EOF
    'change style by () - eg: Slides.Add(X,5) = ppLayoutTextAndObject
    Set objSlide = objPresentation.Slides.Add(1, 5)
    Set objShapes = objSlide.Shapes

    Set objTitle = objShapes.Item(1)
    objTitle.TextFrame.TextRange.Text = objRecordset.Fields.Item("Address") &_
    ", " & objRecordset.Fields.Item("City Name") & vbTab &_
    "$" & objRecordset.Fields.Item("List Price")

    Set objTitle = objShapes.Item(2)
    objTitle.TextFrame.TextRange.Text = objRecordset.Fields.Item("ML
    Number") & Chr(13) &_
    objRecordset.Fields.Item("Bedrooms") & " Bedrooms" & Chr(13) &_
    objRecordset.Fields.Item("Bathrooms") & " Bathrooms" & Chr(13) &_
    objRecordset.Fields.Item("Sq Foot") & " Sq. Feet"

    Set objTitle = objShapes.Item(3)
    'objTitle.AddPicture - comes up Object does not support property or method
    'objTitle.AddPicture = "filename=C:\temp\RESI_BBE\24121779.jpg"


    objRecordset.MoveNext
    Loop
     
    Robert, Dec 18, 2005
    #1
    1. Advertisements

  2. Robert

    Olivier Rassi

    Joined:
    May 15, 2015
    Messages:
    1
    Likes Received:
    0
    Hello,

    I am also working on scripting PPT. I have a PPT presentation in which I need to modify some content. So far I've been able to modify text, table cells and titles, but I don't know how to modify an already existing picture. While using Powerpoint you simply right-click on the image, and select "Change Picture". But I can't find how to do that from script.

    For adding a picture, it is quite simple. You should write:
    objShapes.AddPicture "C:\temp\RESI_BBE\24121779.jpg", False, True, 10, 15

    where 10 and 15 are positioning left and top. I don't know yet what False and True are for, and I don't know how to resize the picture if necessary. I'm still looking but I'm having trouble finding documentation.
     
    Olivier Rassi, May 15, 2015
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.