Jan 24
Over at the Ruby on Windows blog, David posted an article about how the latest versions of Office allow for saving files as PDF. Which prompted me to ask how you can find out what the versions are, since Office 2003 apps don’t have this option. So in between watching the AFC Championship game, I figured it out and came up with the following program:
require 'win32ole' xl = WIN32OLE.new('Excel.Application') xl.visible = false ver = nil case xl.Version when "12.0" ver = "Excel 2007" when "11.0" ver = "Excel 2003" else ver = "{Unknown Version => #{xl.Version}}" end puts " Excel Version: #{ver}" xl.Quit word = WIN32OLE.new('Word.Application') word.visible = false ver = nil case word.Version when "12.0" ver = "Word 2007" when "11.0" ver = "Word 2003" else ver = "{Unknown Version => #{word.Version}}" end puts " Word Version: #{ver}" word.Quit ppt = WIN32OLE.new('Powerpoint.Application') #ppt.visible = false ## Powerpoint 2007 does not allow itself to be hidden?!? ver = nil case ppt.Version when "12.0" ver = "Powerpoint 2007" when "11.0" ver = "Powerpoint 2003" else ver = "{Unknown Version => #{ppt.Version}}" end puts "Powerpoint Version: #{ver}" ppt.Quit ol = WIN32OLE.new('Outlook.Application') #ol.visible = false ver = nil ## Outlook seems to tack on a build number tt = ol.Version.slice(0,4) case tt when "12.0" ver = "Outlook 2007" when "11.0" ver = "Outlook 2003" else ver = "{Unknown Version => #{ol.Version}}" end puts " Outlook Version: #{ver}" ol.Quit