Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3608706
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:32:05+00:00 2026-05-18T21:32:05+00:00

I just put together a small script for a team of users that collects

  • 0

I just put together a small script for a team of users that collects all PDF and DOC* files in a directory and parses them for hyperlinks. The PDF section works as intended, however a difference between the Word doc I was given for design (plain text) differs from the actual Word documents that they are using (text is in a TextBox element).

I noticed that when I tried to gather sentences/words from these new files, all I received was the text for the background image of the file (normally a special character).

I have browsed through the API and tried quite a few methods listed in ole_methods, but have not yet found a way to access the TextBox to pull the required text out of it.

I know that I can convert the Word files to PDF and shortcut it that way (tested and proven), but that entails quite a bit of file management that I’d like to avoid in lieu of the simpler solution: access the text.

You can replicate the element in a document using the Draw Text Box function (Word 2007+).

Does anyone know how to access this element, or better yet find ALL text in the document regardless of what element it is located in?

require 'win32ole'
word = WIN32OLE.new('Word.Application')
doc = word.Documents.Open(file)
doc.Sentences.each { |x| puts x.text }
  • Adam
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:32:06+00:00Added an answer on May 18, 2026 at 9:32 pm

    Assuming that something equivalent to doc.Sentences.each { |x| puts x.text } but for textboxes will suffice, then this should work for you:

    doc.Shapes.each do |x|
      puts x.TextFrame.TextRange.text
    end
    

    It looks quite a bit messier than how you went through the sentences, but the x.TextFrame.TextRange.text will return the actual text contained in the text boxes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I put together a quick sample just to test out the garbage collection convenience
I have recently put together a JWS application which gets it's argument from a
I'm investigating a personal Grails project and want to put together a domain model
I've ran into an issue while trying to put together a Grails app with
I have a bunch of related Perl scripts that I would like to put
I am creating a little gallery using jQuery and stuck on a small point
I'm putting together a sprite and have two questions. Something I've always wondered whether
This is a Java syntax question, but just for some background. Using android, I
This is a little related to my previous question Solaris: Mounting a file system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.