How to add a picuture to a slide in powerpoint

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=‘C:\VBA\rpt.bmp’

begin
ppt = WIN32OLE.new(‘Powerpoint.Application’)
ppt.Visible = true
doc = ppt.Presentations.Add()
ppLayoutText = 2
slide1 = doc.Slides.Add(1, ppLayoutText)

slide.Shapes.AddPicture(
{

‘FileName’=> in_file,
‘Left’=>100,
‘Top’=>100,
‘Width’=>70,
‘Height’=>70

}

)

rescue

ensure

ppt.Quit()
end

oops,typo. “slide” should be “slide1”.

Li

On Oct 18, 12:17 pm, Li Chen [email protected] wrote:

slide.Shapes.AddPicture(

rescue

ensure

ppt.Quit()
end

Posted viahttp://www.ruby-forum.com/.

Give this a try:

slide1.Shapes.AddPicture(
{
‘FileName’=> in_file,
‘LinkToFile’ => false,
‘SaveWithDocument’ => true,
‘Left’ => 100,
‘Top’ => 100,
‘Width’ => 70,
‘Height’ => 70
}
)

Required parameters are:

FileName
LinkToFile
SaveWithDocument
Left
Top

David

http://rubyonwindows.blogspot.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs