Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2014, 06:59 PM
tingker tingker is offline Replace 0000s with a series of numbers Windows 7 64bit Replace 0000s with a series of numbers Office 2010 64bit
Novice
Replace 0000s with a series of numbers
 
Join Date: Dec 2014
Posts: 6
tingker is on a distinguished road
Default Replace 0000s with a series of numbers


Hello,
I need help again, creating macros. I have over 100 hundred files that I need to edit. Any input will be greatly appreciated!

I have a word file that looks like below, and I need to replace the 000's with a new set of numbers from a separate word file.

Quiz File (word file 1):
<question sample-global-id=”00000000000000000000” type=”mc”>
1. What is development?

a. a quantitative change in the individual over time
b. an event that is predictable and consistent for all persons
c. the orderly appearance over time of physical structures, psychological traits, and behaviours
d. a qualitative change in the individual over time

<question sample-global-id=”00000000000000000000” type=”mc”>
2. How have children been viewed historically?

a. as innately good and only in need of gentle discipline
b. as miniature adults after age five, or the “age of reason”
c. as clean slates changed by experience
d. as little sponges who want to absorb the world

Number File (word file 2):
QDGGHR3YXNQ2WFLDB976
JEDCNUEPNYP2N8ESP596

Is it possible to have a macro that will insert the numbers from a different word file into my quiz file?

Thank you very much! I'm attaching the word file for reference.
Attached Files
File Type: docx QDGGHR3YXNQ2WFLDB976.docx (14.0 KB, 10 views)
File Type: docx 9780176679903_rathus2ce_mc_ch01.docx (28.3 KB, 9 views)
Reply With Quote
  #2  
Old 12-16-2014, 11:30 PM
gmayor's Avatar
gmayor gmayor is offline Replace 0000s with a series of numbers Windows 7 64bit Replace 0000s with a series of numbers Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 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
  #3  
Old 12-17-2014, 06:06 AM
tingker tingker is offline Replace 0000s with a series of numbers Windows 7 64bit Replace 0000s with a series of numbers Office 2010 64bit
Novice
Replace 0000s with a series of numbers
 
Join Date: Dec 2014
Posts: 6
tingker is on a distinguished road
Default

gmayor, thanks very much. It worked perfectly! Much appreciated.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
search and replace a field containing text and numbers H28Sailor Word 6 09-11-2014 01:00 AM
find and replace consecutive numbers kpl_39 Word 1 06-07-2013 05:04 AM
Replace 0000s with a series of numbers Find & Replace formula for numbers? Griff Word 4 04-18-2011 02:47 AM
Find and replace page numbers in body of text tollanarama Word 3 02-13-2011 06:00 AM
Replace 0000s with a series of numbers replace automatically generated page numbers LitWissOnline Word 3 01-24-2011 03:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:53 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