Ruby and Windows Automation

From PeformIQ Upgrade
Revision as of 09:48, 12 March 2010 by PeterHarding (talk | contribs)
Jump to navigation Jump to search

References

Functions

Miscellaneous function in the API...

excel = WIN32OLE.new('Excel.Application')

book = excel.Workbooks.Add()

sheet = book.Worksheets(1)

excel.Visible = true

range = sheet.Range('A1').Resize(data.size, data.first.size)
range.Value = data

sheet.Rows(1).AutoFilter()

iTunes

require 'win32ole'

app = WIN32OLE.new('iTunes.Application')

data = []

app.LibraryPlaylist.Tracks.each do |track|
  if not track.Podcast
    data << [track.Artist, track.Year, track.Album, track.Name]
  end
end

data.sort!

data.insert(0, ['ARTIST', 'YEAR', 'ALBUM', 'NAME'])

MSDN Links

Constants

Constants

From: http://ruby-doc.org/core/classes/WIN32OLE.html

module EXCEL_CONST
end
excel = WIN32OLE.new('Excel.Application')
WIN32OLE.const_load(excel, EXCEL_CONST)
puts EXCEL_CONST::XlTop # => -4160
puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541

WIN32OLE.const_load(excel)
puts WIN32OLE::XlTop # => -4160

module MSO
end
WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO)
puts MSO::MsoLineSingle # => 1
WIN32OLE.new('Excel.Application') # => Excel OLE Automation WIN32OLE object.
WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object.