Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 09-08-2016, 10:06 PM
gmayor's Avatar
gmayor gmayor is offline Extract a string from a paragraph Windows 10 Extract a string from a paragraph Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
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

It has nothing to do with the sequence, but the fact that sequence will never appear in the current paragraph, because of ^p which makes the search across two paragraphs. Use instead

Code:
Sub Macro2()
Dim oRng As Range
Dim oPara As Paragraph
Dim sText As String
    For Each oPara In ActiveDocument.Paragraphs
        Set oRng = oPara.Range
        With oRng.Find
            Do While .Execute(FindText:="010^t")
                If oRng.start = oPara.Range.start Then
                    sText = Replace(oRng.Text, Chr(9), "")
                    'do something with stext e.g.
                    MsgBox sText
                End If
                oRng.Collapse 0
            Loop
        End With
    Next oPara
lbl_Exit:
    Set oRng = Nothing
    Set oPara = Nothing
    Exit Sub
End Sub
__________________
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
Extract a string from a paragraph How to extract a word from an excel string with various lengths keywestsue Excel 3 09-18-2015 07:32 AM
How to extract only numbers from a STRING? Learner7 Excel 3 07-02-2013 06:25 AM
Extract a string from a paragraph Extract Numbers from Alphanumeric String OTPM Excel 6 05-13-2011 12:52 AM
Extract numbers from a text string aleale97 Excel 4 02-10-2011 10:33 AM
Extract from String using Wildcard whousedmy Word 0 05-21-2009 01:35 AM

Other Forums: Access Forums

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


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