Class: Word

Inherits:
Object show all
Defined in:
lib/helpers/jruby/word.rb,
lib/helpers/jruby/word.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(visible) ⇒ Word

Returns a new instance of Word.



38
39
40
41
42
43
44
# File 'lib/helpers/jruby/word.rb', line 38

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

#docObject (readonly)

Returns the value of attribute doc.



36
37
38
# File 'lib/helpers/jruby/word.rb', line 36

def doc
  @doc
end

#wdObject (readonly)

Returns the value of attribute wd.



36
37
38
# File 'lib/helpers/jruby/word.rb', line 36

def wd
  @wd
end

Instance Method Details

#open(file) ⇒ Object



46
47
48
49
# File 'lib/helpers/jruby/word.rb', line 46

def open(file)
  @doc = @wd.Documents.Open(file)
  @doc
end

#quitObject



70
71
72
# File 'lib/helpers/jruby/word.rb', line 70

def quit
  @wd.quit()
end

#saveObject



51
52
53
54
# File 'lib/helpers/jruby/word.rb', line 51

def save()
  @doc.Save()
  @doc
end

#save_as(name, format) ⇒ Object

Format : From WORD_OLE_CONST e.g WORD_OLE_CONST::WdFormatHTML



58
59
60
61
# File 'lib/helpers/jruby/word.rb', line 58

def save_as(name, format)
  @doc.SaveAs(name, format)
  return @doc
end

#save_as_html(name) ⇒ Object

WdFormatFilteredHTML WdFormatHTML



65
66
67
68
# File 'lib/helpers/jruby/word.rb', line 65

def save_as_html(name)
  @doc.SaveAs(name, WORD_OLE_CONST::WdFormatHTML)
  return @doc
end