View Single Post
 
Old 08-31-2014, 10:08 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
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

I have had a look at your document and it appears you missed a vital piece of information! The document text is contained in a field result. It is much simpler just to extract the field result e.g.

Code:
Function ExtractTextENV(oDoc As Document) As Boolean
Dim oNewDoc As Document
Dim strNewName As String
Dim oFld As Field
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
    If InStr(1, oDoc.Range, strStart) > 0 And oDoc.Range.Fields.Count > 2 Then
        Set oNewDoc = Documents.Add(Visible:=False)
        oNewDoc.Range.Text = strStart & vbCr & oDoc.Range.Fields(2).Result & vbCr & strEnd
        oNewDoc.Range.Font.Reset
        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
    Else
        GoTo Err_Handler:
    End If
    ExtractTextENV = True
lbl_Exit:
    Exit Function
Err_Handler:
    ExtractTextENV = False
End Function
If the documents are password protected for forms, then click the require password check box.

Great lyric choice!
__________________
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