123456789_123456789_123456789_123456789_123456789_

Class: WIN32OLE_TYPE

Relationships & Source Files
Inherits: Object
Defined in: ext/win32ole/win32ole_type.c,
ext/win32ole/win32ole_type.c

Overview

WIN32OLE_TYPE objects represent OLE type libarary information.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(typelib, ole_class) ⇒ WIN32OLE_TYPE

Returns a new WIN32OLE_TYPE object. The first argument typelib specifies OLE type library name. The second argument specifies OLE class name.

WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
    # => WIN32OLE_TYPE object of Application class of Excel.

Class Method Details

.ole_classes(typelib)

Returns array of WIN32OLE_TYPE objects defined by the typelib type library. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.new(typelib).ole_classes instead.

.progids

Returns array of ProgID.

.typelibs

Returns array of type libraries. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead.

Instance Attribute Details

#visible?(#=> true or false) (readonly)

Returns true if the OLE class is public.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.visible  # => true

Instance Method Details

#default_event_sources

Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.

tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
p tobj.default_event_sources  # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]

#default_ole_types

Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FDEFAULT.

tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
p tobj.default_ole_types
# => [#<WIN32OLE_TYPE:IWebBrowser2>, #<WIN32OLE_TYPE:DWebBrowserEvents2>]

#guid(#=> GUID)

Returns GUID.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.guid  # => {00024500-0000-0000-C000-000000000046}

#helpcontext

Returns helpcontext. If helpcontext is not found, then returns nil.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
puts tobj.helpfile # => 131185

#helpfile

Returns helpfile path. If helpfile is not found, then returns nil.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
puts tobj.helpfile # => C:\...\VBAXL9.CHM

#helpstring(#=> help string.)

Returns help string.

tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser')
puts tobj.helpstring # => Web Browser interface

#implemented_ole_types

Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
p tobj.implemented_ole_types # => [_Worksheet, DocEvents]

#inspectString

Returns the type name with class name.

ie = WIN32OLE.new('InternetExplorer.Application')
ie.ole_type.inspect => #<WIN32OLE_TYPE:IWebBrowser2>

#major_version

Returns major version.

tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
puts tobj.major_version # => 8

#minor_version(#=> OLE minor version)

Returns minor version.

tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
puts tobj.minor_version # => 2

#to_s(#=> OLE type name) #name(#=> OLE type name)

Alias for #to_s.

#ole_methods(# the array of WIN32OLE_METHOD objects.)

Returns array of ::WIN32OLE_METHOD objects which represent OLE method defined in OLE type library.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
methods = tobj.ole_methods.collect{|m|
  m.name
}
# => ['Activate', 'Copy', 'Delete',....]

#ole_type(#=> OLE type string.)

returns type of OLE class.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.ole_type  # => Class

#ole_typelib

Returns the ::WIN32OLE_TYPELIB object which is including the WIN32OLE_TYPE object. If it is not found, then returns nil.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
puts tobj.ole_typelib # => 'Microsoft Excel 9.0 Object Library'

#progid(#=> ProgID)

Returns ProgID if it exists. If not found, then returns nil.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.progid  # =>   Excel.Application.9

#source_ole_types

Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE.

tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
p tobj.source_ole_types
# => [#<WIN32OLE_TYPE:DWebBrowserEvents2>, #<WIN32OLE_TYPE:DWebBrowserEvents>]

#src_type(#=> OLE source class)

Returns source class when the OLE class is 'Alias'.

tobj =  WIN32OLE_TYPE.new('Microsoft Office 9.0 Object Library', 'MsoRGBType')
puts tobj.src_type # => I4

#to_s(#=> OLE type name) Also known as: #name

Returns OLE type name.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.name  # => Application

#typekind(#=> number of type.)

Returns number which represents type.

tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
puts tobj.typekind # => 4

#variables

Returns array of ::WIN32OLE_VARIABLE objects which represent variables defined in OLE class.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
vars = tobj.variables
vars.each do |v|
  puts "#{v.name} = #{v.value}"
end

The result of above sample script is follows:
  xlChart = -4109
  xlDialogSheet = -4116
  xlExcel4IntlMacroSheet = 4
  xlExcel4MacroSheet = 3
  xlWorksheet = -4167