Class: WIN32OLE
- Inherits:
-
Object
- Object
- WIN32OLE
- Defined in:
- win32ole.c,
win32ole.c
Overview
WIN32OLE objects represent OLE Automation object in Ruby.
Direct Known Subclasses
Defined Under Namespace
Modules: VARIANT
Constant Summary collapse
- VERSION =
rb_str_new2(WIN32OLE_VERSION)
- ARGV =
rb_ary_new()
- CP_THREAD_ACP =
INT2FIX(CP_THREAD_ACP)
Class Method Summary collapse
-
.codepage ⇒ Object
Returns current codepage.
-
.codepage=(CP) ⇒ Object
Sets current codepage.
-
.connect(ole) ⇒ Object
Returns running OLE Automation object or WIN32OLE object from moniker.
-
.const_load(ole, mod = WIN32OLE) ⇒ Object
Defines the constants of OLE Automation server as mod's constants.
-
.ole_free(aWIN32OLE) ⇒ Object
Invokes Release method of Dispatch interface of WIN32OLE object.
-
.ole_reference_count(aWIN32OLE) ⇒ Object
Returns reference counter of Dispatch interface of WIN32OLE object.
-
.ole_show_help(obj[,helpcontext]) ⇒ Object
Displays helpfile.
Instance Method Summary collapse
-
#[]('property') ⇒ Object
Returns property of OLE object.
-
#[]= ⇒ Object
Sets property of OLE object.
-
#_getproperty(dispid, args, types) ⇒ Object
Runs the early binding method to get property.
-
#_invoke(dispid, args, types) ⇒ Object
Runs the early binding method.
-
#_setproperty(dispid, args, types) ⇒ Object
Runs the early binding method to set property.
-
#each {|i| ... } ⇒ Object
Iterates over each item of OLE collection which has IEnumVARIANT interface.
-
#new(server, [host]) ⇒ WIN32OLE object
constructor
Returns a new WIN32OLE object(OLE Automation object).
-
#invoke(method, [arg1,...]) ⇒ Object
Runs OLE method.
-
#method_missing(id[,arg1, arg2, ...]) ⇒ Object
Calls WIN32OLE#invoke method.
-
#ole_free ⇒ Object
invokes Release method of Dispatch interface of WIN32OLE object.
-
#ole_func_methods ⇒ Object
Returns the array of WIN32OLE_METHOD object .
-
#ole_get_methods ⇒ Object
Returns the array of WIN32OLE_METHOD object .
-
#ole_method_help(method) ⇒ Object
(also: #ole_method_help)
Returns WIN32OLE_METHOD object corresponding with method specified by 1st argument.
-
#ole_methods ⇒ Object
Returns the array of WIN32OLE_METHOD object.
-
#ole_obj_help ⇒ Object
Returns WIN32OLE_TYPE object.
-
#ole_put_methods ⇒ Object
Returns the array of WIN32OLE_METHOD object .
-
#setproperty ⇒ Object
Sets property of OLE object.
Constructor Details
#new(server, [host]) ⇒ WIN32OLE object
Returns a new WIN32OLE object(OLE Automation object). The first argument server specifies OLE Automation server. The first argument should be CLSID or PROGID. If second argument host specified, then returns OLE Automation object on host.
WIN32OLE.new('Excel.Application') # => Excel OLE Automation WIN32OLE object.
WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object.
1864 1865 1866 |
# File 'win32ole.c', line 1864 static VALUE fole_initialize(argc, argv, self) int argc; |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id[,arg1, arg2, ...]) ⇒ Object
Calls WIN32OLE#invoke method.
2672 2673 2674 |
# File 'win32ole.c', line 2672 static VALUE fole_missing(argc, argv, self) int argc; |
Class Method Details
.codepage ⇒ Object
Returns current codepage. WIN32OLE.codepage # => WIN32OLE::CP_ACP
1803 1804 1805 |
# File 'win32ole.c', line 1803 static VALUE fole_s_get_code_page(self) VALUE self; |
.codepage=(CP) ⇒ Object
Sets current codepage. WIN32OLE.codepage = WIN32OLE::CP_UTF8
1817 1818 1819 |
# File 'win32ole.c', line 1817 static VALUE fole_s_set_code_page(self, vcp) VALUE self; |
.connect(ole) ⇒ Object
Returns running OLE Automation object or WIN32OLE object from moniker. 1st argument should be OLE program id or class id or moniker.
WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel.
1486 1487 1488 |
# File 'win32ole.c', line 1486 static VALUE fole_s_connect(argc, argv, self) int argc; |
.const_load(ole, mod = WIN32OLE) ⇒ Object
Defines the constants of OLE Automation server as mod's constants. The first argument is WIN32OLE object or type library name. If 2nd argument is omitted, the default is WIN32OLE. The first letter of Ruby's constant variable name is upper case, so constant variable name of WIN32OLE object is capitalized. For example, the 'xlTop' constant of Excel is changed to 'XlTop' in WIN32OLE. If the first letter of constant variabl is not [A-Z], then the constant is defined as CONSTANTS hash element.
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
1569 1570 1571 |
# File 'win32ole.c', line 1569 static VALUE fole_s_const_load(argc, argv, self) int argc; |
.ole_free(aWIN32OLE) ⇒ Object
Invokes Release method of Dispatch interface of WIN32OLE object. You should not use this method because this method exists only for debugging WIN32OLE. The return value is reference counter of OLE object.
1711 1712 1713 |
# File 'win32ole.c', line 1711 static VALUE fole_s_free(self, obj) VALUE self; |
.ole_reference_count(aWIN32OLE) ⇒ Object
Returns reference counter of Dispatch interface of WIN32OLE object. You should not use this method because this method exists only for debugging WIN32OLE.
1692 1693 1694 |
# File 'win32ole.c', line 1692 static VALUE fole_s_reference_count(self, obj) VALUE self; |
.ole_show_help(obj[,helpcontext]) ⇒ Object
1761 1762 1763 |
# File 'win32ole.c', line 1761 static VALUE fole_s_show_help(argc, argv, self) int argc; |
Instance Method Details
#[]('property') ⇒ Object
2488 2489 2490 |
# File 'win32ole.c', line 2488 static VALUE fole_getproperty(argc, argv, self) int argc; |
#[]=('property') ⇒ Object #setproperty('property', [arg1, arg2,...]) ⇒ Object
2470 2471 2472 |
# File 'win32ole.c', line 2470 static VALUE fole_setproperty(argc, argv, self) int argc; |
#_getproperty(dispid, args, types) ⇒ Object
Runs the early binding method to get property. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments.
excel = WIN32OLE.new('Excel.Application')
puts excel._getproperty(558, [], []) # same effect as puts excel.visible
2424 2425 2426 |
# File 'win32ole.c', line 2424 static VALUE fole_getproperty2(self, dispid, args, types) VALUE self; |
#_invoke(dispid, args, types) ⇒ Object
2402 2403 2404 |
# File 'win32ole.c', line 2402 static VALUE fole_invoke2(self, dispid, args, types) VALUE self; |
#_setproperty(dispid, args, types) ⇒ Object
Runs the early binding method to set property. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments.
excel = WIN32OLE.new('Excel.Application')
excel._setproperty(558, [true], [WIN32OLE::VARIANT::VT_BOOL]) # same effect as excel.visible = true
2446 2447 2448 |
# File 'win32ole.c', line 2446 static VALUE fole_setproperty2(self, dispid, args, types) VALUE self; |
#each {|i| ... } ⇒ Object
2614 2615 2616 |
# File 'win32ole.c', line 2614 static VALUE fole_each(self) VALUE self; |
#invoke(method, [arg1,...]) ⇒ Object
2187 2188 2189 |
# File 'win32ole.c', line 2187 static VALUE fole_invoke(argc, argv, self) int argc; |
#ole_free ⇒ Object
invokes Release method of Dispatch interface of WIN32OLE object. Usually, you do not need to call this method because Release method called automatically when WIN32OLE object garbaged.
2562 2563 2564 |
# File 'win32ole.c', line 2562 static VALUE fole_free(self) VALUE self; |
#ole_func_methods ⇒ Object
2975 2976 2977 |
# File 'win32ole.c', line 2975 static VALUE fole_func_methods( self ) VALUE self; |
#ole_get_methods ⇒ Object
2940 2941 2942 |
# File 'win32ole.c', line 2940 static VALUE fole_get_methods( self ) VALUE self; |
#ole_method_help(method) ⇒ Object Also known as: ole_method_help
3236 3237 3238 |
# File 'win32ole.c', line 3236 static VALUE fole_method_help( self, cmdname ) VALUE self; |
#ole_methods ⇒ Object
2923 2924 2925 |
# File 'win32ole.c', line 2923 static VALUE fole_methods( self ) VALUE self; |
#ole_obj_help ⇒ Object
2991 2992 2993 |
# File 'win32ole.c', line 2991 static VALUE fole_obj_help( self ) VALUE self; |
#ole_put_methods ⇒ Object
2957 2958 2959 |
# File 'win32ole.c', line 2957 static VALUE fole_put_methods( self ) VALUE self; |
#[]=('property') ⇒ Object #setproperty('property', [arg1, arg2,...]) ⇒ Object
2470 2471 2472 |
# File 'win32ole.c', line 2470 static VALUE fole_setproperty(argc, argv, self) int argc; |