2008년 9월 3일 수요일

Automating Powerpoint with ruby

크롬에서 첫번째 써보는 글.

Automating Powerpoint with ruby 에 소개된 루비로 파워포인트 다루는 예제 소스를 살짝 수정해보았다. 
require 'win32ole'

ppt_file = ARGV[0]
exp_file = ppt_file.sub(/\.ppt$/i, '')

# open powerpoint
ppt = WIN32OLE.new('Powerpoint.Application')
# make sure it is visible
ppt.Visible = true
# open the presentation to be exported
pre = ppt.Presentations.Open(ppt_file)

# export the file
(1..pre.Slides.count).each do |i|
    pre.Slides(i).Export("#{exp_file}_#{i}.png", "png")
end

# close powerpoint, will close all the currently open files
ppt.Quit()
Ruby + Powerpoint 관련해서는 아래 블로그도 볼만하다.

댓글 없음:

댓글 쓰기