Connecting Tech Pros Worldwide Help | Site Map

Parse Word document to upload data to database

  #1  
Old June 11th, 2009, 12:18 PM
Newbie
 
Join Date: Jun 2009
Posts: 1
hi dudes

can anyone there guide me in parsing word document to upload the data from word doc to d/b using ruby on rails... It would be helpful if i get a sample description of that code...
  #2  
Old June 14th, 2009, 02:41 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,517
Provided Answers: 12

re: Parse Word document to upload data to database


I've moved your post to the correct place, so that the experts can have a look at it and perhaps provide some clues. Oh, and welcome to Bytes!

-Moderator
  #3  
Old June 15th, 2009, 06:04 PM
Expert
 
Join Date: May 2007
Posts: 213

re: Parse Word document to upload data to database


You can use win32ole to parse the Word documents, then just grab the text and save it in the database. Here's an example for getting text out of a Word document:
Expand|Select|Wrap|Line Numbers
  1. require 'win32ole'
  2. word = WIN32OLE.new('word.application')
  3. word.documents.open(path_to_file)
  4.  
  5. # select whole text
  6. word.selection.wholestory
  7.  
  8. # read the selection
  9. puts word.selection.text.chomp
  10.  
  11. # close document
  12. word.activedocument.close( false ) # no save dialog, just close it
  13.  
  14. # quit word
  15. word.quit
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help gunimpi answers 0 January 10th, 2007 08:55 PM