Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 08-28-2014, 07:38 AM
gmayor's Avatar
gmayor gmayor is offline We have many word docs we need to copy text from Windows 7 64bit We have many word docs we need to copy text from Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Having re-read the question, I think there is enough information to suggest a function. Open a document with the required text and test with the following to see if it gives you the results you want:

Code:
Sub Test()
ExtractText ActiveDocument
End Sub
If it does then run it as a custom process from the aforementioned add-in
Try it on a small group of three or four files first. The function puts the files in the same folder as the documents, but you can change the path if you wish.


Code:
Function ExtractText(oDoc As Document) As Boolean
Dim oRng As Range
Dim oNewRange As Range
Dim oNewDoc As Document
Dim strNewName As String
Const strStart As String = "The information received does not support the service requested:"
Const strEnd As String = "The above actions are supported by the following:"
    On Error GoTo Err_Handler
    Set oRng = oDoc.Range
    With oRng
        .Start = .Start + InStr(oRng, strStart) - 1
        .End = .Start + InStr(oRng, strEnd) - 1
        If Len(.Text) > 0 Then
            Set oNewDoc = Documents.Add(Template:=oDoc.FullName, Visible:=False)
            oNewDoc.Range.FormattedText = oRng.FormattedText
            Set oNewRange = oNewDoc.Range
            oNewRange.Collapse wdCollapseStart
            oNewRange.MoveEndUntil ":"
            oNewRange.End = oNewRange.End + 2
            oNewRange.Delete
            strNewName = oDoc.FullName
            strNewName = Left(strNewName, InStrRev(strNewName, Chr(46)) - 1)
            strNewName = strNewName & "EN"
            strNewName = strNewName & Right(oDoc.name, Len(oDoc.name) - InStrRev(oDoc.name, Chr(46)) + 1)
            oNewDoc.SaveAs strNewName, addtorecentfiles:=False
            oNewDoc.Close 0
        End If
    End With
    ExtractText = True

lbl_Exit:
    Exit Function
Err_Handler:
    ExtractText = False
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Text Twice to Paste into word Albundy Word 2 09-02-2016 12:59 PM
Text Shifting When Saving Word 2007 Docs DerekS Word 1 09-21-2013 02:42 AM
Can't copy/cut and paste text in Word 2002 mmiller751 Word 0 04-17-2012 02:55 PM
We have many word docs we need to copy text from copy from word into a formatting text box mikewooten Word 1 06-15-2010 02:04 AM
We have many word docs we need to copy text from Is it possible to create 'balloon' text in docs bubbleboi Word 3 11-13-2009 01:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:50 AM.


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