I've got this piece of code that works for Excel.
require 'win32ole'
excel = WIN32OLE.new('Excel.Application')
excel.visible = true
workbook = excel.Workbooks.Open('c:\file.xls');
But I have trouble getting the same thing done with for PowerPoint; This piece of code:
require 'win32ole'
ppt = WIN32OLE.new('Powerpoint.Application')
ppt.visible = true
presentation = ppt.Presentations.Open('c:\file.pptx');
Generates this error:
filename.rb in `method_missing': (in OLE method `Open': ) (WIN32OLERuntimeError)
OLE error code:80004005 in <Unknown>
<No Description>
HRESULT error code:0x80020009
Exception occurred.
Microsoft Support site says that the only required parameter is the filename.
I've found an ugly workaround:
require 'win32ole'
require 'fileutils'
ppt = WIN32OLE.new('PowerPoint.Application')
ppt.visible = true
system "start c:/presentation.ppt"
puts ppt.ActivePresentation.Slides.Count()
ppt.ActivePresentation.Slides(2).Export("filename.jpg", ".jpg", 1024,768)
ppt.ActivePresentation.Close();