Class: Word
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#wd ⇒ Object
readonly
Returns the value of attribute wd.
Instance Method Summary collapse
-
#initialize(visible) ⇒ Word
constructor
A new instance of Word.
- #open(file) ⇒ Object
- #quit ⇒ Object
- #save ⇒ Object
-
#save_as(name, format) ⇒ Object
Format : From WORD_OLE_CONST e.g WORD_OLE_CONST::WdFormatHTML.
-
#save_as_html(name) ⇒ Object
WdFormatFilteredHTML WdFormatHTML.
Constructor Details
#initialize(visible) ⇒ Word
Returns a new instance of Word.
35 36 37 38 39 40 41 |
# File 'lib/engine/word.rb', line 35 def initialize( visible ) @wd = WIN32OLE.new('Word.Application') WIN32OLE.const_load(@wd, WORD_OLE_CONST) if WORD_OLE_CONST.constants.empty? @wd.Visible = visible end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
33 34 35 |
# File 'lib/engine/word.rb', line 33 def doc @doc end |
#wd ⇒ Object (readonly)
Returns the value of attribute wd.
33 34 35 |
# File 'lib/engine/word.rb', line 33 def wd @wd end |
Instance Method Details
#open(file) ⇒ Object
43 44 45 46 |
# File 'lib/engine/word.rb', line 43 def open(file) @doc = @wd.Documents.Open(file) @doc end |
#quit ⇒ Object
67 68 69 |
# File 'lib/engine/word.rb', line 67 def quit @wd.quit() end |
#save ⇒ Object
48 49 50 51 |
# File 'lib/engine/word.rb', line 48 def save() @doc.Save() @doc end |
#save_as(name, format) ⇒ Object
Format : From WORD_OLE_CONST e.g WORD_OLE_CONST::WdFormatHTML
55 56 57 58 |
# File 'lib/engine/word.rb', line 55 def save_as(name, format) @doc.SaveAs(name, format) return @doc end |
#save_as_html(name) ⇒ Object
WdFormatFilteredHTML WdFormatHTML
62 63 64 65 |
# File 'lib/engine/word.rb', line 62 def save_as_html(name) @doc.SaveAs(name, WORD_OLE_CONST::WdFormatHTML) return @doc end |