-
-
Save rdapaz/06b6fe7ea8ac80043c0ea44b5020b6d8 to your computer and use it in GitHub Desktop.
Ruby: Manipulate MSWord Docs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w(pp win32ole).each {|dep| require dep} | |
begin | |
$app = WIN32OLE.connect('Word.Application') | |
rescue Exception => e | |
$app = WIN32OLE.new('Word.Application') | |
end | |
$app.Visible = true | |
class WordConst | |
end | |
# WIN32OLE.const_load($app,WordConst) | |
path_to_doc = 'C:\Users\rdapaz\Dropbox\Karara\FDS\1300-IN-SPC-1017_E.doc' | |
path_to_doc = 'C:\Users\rdapaz\Dropbox\Karara\FDS\1300-IN-SPC-1018_0.doc' | |
$doc = $app.Documents.Open(path_to_doc) | |
$doc.Paragraphs.each do |para| | |
puts para.Range.Text if para.Style.NameLocal =~/Heading/ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment