On Oct 18, 12:17=A0pm, Li Chen <chen_... / yahoo.com> wrote: > Hi all, > > I want to add a picture to a slide in ppt. > I copy a script from a website and look for MS website.I come out with > my solution of adding a picture but it doesn't work. I wonder which > method is used to add a picture to a slide in powerpoint? > > Thanks, > > Li > > require 'win32ole' > in_file=3D'C:\VBA\rpt.bmp' > > begin > ppt =3D WIN32OLE.new('Powerpoint.Application') > ppt.Visible =3D true > doc =3D ppt.Presentations.Add() > ppLayoutText =3D 2 > slide1 =3D doc.Slides.Add(1, ppLayoutText) > > slide.Shapes.AddPicture( > { > > 'FileName'=3D> in_file, > 'Left'=3D>100, > 'Top'=3D>100, > 'Width'=3D>70, > 'Height'=3D>70 > > =A0 =A0 } > ) > > rescue > > ensure > > ppt.Quit() > end > -- > Posted viahttp://www.ruby-forum.com/. Give this a try: slide1.Shapes.AddPicture( { 'FileName'=3D> in_file, 'LinkToFile' =3D> false, 'SaveWithDocument' =3D> true, 'Left' =3D> 100, 'Top' =3D> 100, 'Width' =3D> 70, 'Height' =3D> 70 } ) Required parameters are: FileName LinkToFile SaveWithDocument Left Top David http://rubyonwindows.blogspot.com