View Single Post
 
Old 12-16-2014, 11:30 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

But for the anomaly that there are 20 codes and only 19 sets of 0s the following will do the job (using the first 19 in the order they appear in the document):

Code:
Sub Replace0s()
Dim oSource As Document
Dim oTarget As Document
Dim oDoc As Document
Dim oRng As Range
Dim oPara As Range
Dim Count As Long
Dim i As Long
    'Open the two documents first
    For Each oDoc In Documents
        If oDoc.name = "QDGGHR3YXNQ2WFLDB976.docx" Then
            Set oSource = oDoc
        ElseIf oDoc.name = "9780176679903_rathus2ce_mc_ch01.docx" Then
            Set oTarget = oDoc
        End If
    Next oDoc
    Count = 0
    Set oRng = oTarget.Range
    With oRng.Find
        Do While .Execute(FindText:="00000000000000000000")
            Count = Count + 1
            Set oPara = oSource.Paragraphs(Count).Range
            oPara.End = oPara.End - 1
            oRng.Text = oPara.Text
            oRng.Collapse 0
        Loop
    End With
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