Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-16-2014, 07:41 AM
SurajJaldu SurajJaldu is offline Issue in reading text Windows 7 64bit Issue in reading text Office 2010 64bit
Novice
Issue in reading text
 
Join Date: Oct 2014
Location: Toronto
Posts: 1
SurajJaldu is on a distinguished road
Default Issue in reading text

Hi,

I am trying to read the text from the attached document. I am able to read all the text starting from 'Dear..'. I am unable to read the other text like 'CurrentDate, WorkerNumber, etc.' which is in Text boxes.

I tried with the following
1. DocObject.ActiveDocument.Content.Text
2. With DocObject
For p = 1 To .ActiveDocument.Paragraphs.Count
startRange = .ActiveDocument.Paragraphs(p).Range.Start
endRange = .ActiveDocument.Paragraphs(p).Range.End
Set tRange = .ActiveDocument.Range(startRange, endRange)
Msgbox tRange.Text
Next
.Close 'close the document


End With

Is there a way to read text from text boxes. I wanted to read the entire text content from the document.

Thanks,
Suraj
Attached Files
File Type: docx Sample.docx (54.4 KB, 6 views)
Reply With Quote
  #2  
Old 10-16-2014, 10:14 AM
gmaxey gmaxey is offline Issue in reading text Windows 7 32bit Issue in reading text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You will have to loop through the document storyranges:

Code:
Public Sub ReadText()
Dim lngJunk As Long
Dim oShp As Shape
Dim rngStory As Word.Range
Dim opar As Paragraph
'Fix the skipped blank Header/Footer problem
lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
'Iterate through all story types in the current document
For Each rngStory In ActiveDocument.StoryRanges
  'Iterate through all linked stories
  Do
    For Each opar In rngStory.Paragraphs
      Debug.Print opar.Range.Text
    Next opar
    On Error Resume Next
    Select Case rngStory.StoryType
      Case 6, 7, 8, 9, 10, 11
        If rngStory.ShapeRange.Count > 0 Then
          For Each oShp In rngStory.ShapeRange
            If oShp.TextFrame.HasText Then
              For Each opar In rngStory.Paragraphs
                 Debug.Print opar.Range.Text
              Next opar
            End If
          Next
        End If
      Case Else
        'Do Nothing
    End Select
    On Error GoTo 0
    'Get next linked story (if any)
    Set rngStory = rngStory.NextStoryRange
  Loop Until rngStory Is Nothing
Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue in reading text Vertical Axis Text Issue word perfect Excel 2 03-20-2013 02:23 PM
Issue in reading text How to save a PPT file in 'Reading View' to be opened always in 'Reading View' ItzVickey PowerPoint 2 08-08-2012 09:23 AM
Issue in reading text Issue: Intermittant Text Enlargement doix Outlook 3 01-04-2012 04:55 AM
Issue in reading text Text box issue Dave Duncan Word 2 08-04-2011 12:25 PM
Issue in reading text problem reading rich text messages Rkaskas Outlook 3 03-14-2011 09:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft