Find and Replace

  • Thread starter Thread starter Glory
  • Start date Start date
G

Glory

I have 2 documents - an original one and a template. Both have 20 sets of the
below information. The "Z plus the numbers" in the original document change
on a daily basis, while everything else stays the same-ditto for the
template. Somehow I have to copy and paste or merge (all at once) the new 20
"Z plus the numbers" from the original document to the template while making
sure that nothing else changes in the template. I could do it one at a time
but it would be too time consuming to do 20 on a daily basis. Does anyone
have any suggestions? I would sure appreciate it - this is work related.
Thank you for any help you can give me,
Glory

Identifier:
Z8082422838
|PIN|: 0882
Patron Type: Sign up for a library card now

Identifier:
Z8082422839
|PIN|: 0993
Patron Type: Sign up for a library card now
 
I have 2 documents - an original one and a template. Both have 20 sets of the
below information. The "Z plus the numbers" in the original document change
on a daily basis, while everything else stays the same-ditto for the
template. Somehow I have to copy and paste or merge (all at once) the new 20
"Z plus the numbers" from the original document to the template while making
sure that nothing else changes in the template. I could do it one at a time
but it would be too time consuming to do 20 on a daily basis. Does anyone
have any suggestions? I would sure appreciate it - this is work related.
Thank you for any help you can give me,
Glory

Identifier:
Z8082422838
|PIN|: 0882
Patron Type: Sign up for a library card now

Identifier:
Z8082422839
|PIN|: 0993
Patron Type: Sign up for a library card now

You don't say, but can we assume the numbers after the Z are sequential? That
is, the next one would be Z8082422840, then Z8082422841, and so on?

Type the beginning of each Z line, as much as won't change -- let's say it's

Z808242

At the end of the first Z line, click Insert > Field. In the dialog, select a
Seq field from the list. In the "field codes" box, make the code look like this:

SEQ a \r 2838

where the number should be the remaining part of whatever number you want to
start with. Click OK.

At the end of the second Z line, again click Insert > Field. This time, make the
code just

SEQ a

and click OK. Select that field, copy it, and paste it at the end of every other
Z line. Finally, press Ctrl+A to select everything, and press F9 to update all
the fields.

The next day, right-click the first SEQ field and choose Toggle Field Code.
Inside the field code, change the number to the new starting number. Then press
Ctrl+A and F9 again, and all the numbers will update.
 
Original document has the information below - the numbers are sequential
both after the Z and the PIN number. I have no control over any of the
information in the original document. However, I need to add the line: Sign
up now for a library card today, to the original document that I am unable to
alter. It is supposed to be added after the Information "Patron Type:" I
came up with the idea of making a template in Word with just the sentence
typed in and somehow copy and paste the new numbers in the template but it's
not working. There are 20 sets of these figures (20 different numbers).

Identifier:
Z8082422838
|PIN|: 0882
Patron Type:

Identifier:
Z8082422839
|PIN|: 0993
Patron Type:

The template has just one line: Sign up today for a library card now

Somehow I need to combine both sets of information - source document cannot
be altered by me but I can copy and paste to a template each day and add the
new sentence. I just didn't want to have to do it 20 times a day, sometimes
I need 30 sets of these numbers. I wanted to be able to accomplish this with
just one stroke of the brush. This information is used by libraries for the
public to be able to use the computers. Each person has to have his own
special sequence of numbers to be able to log on to our computers. Would
another program work better? As in Excell? Thank you for trying to help me.
Glory
 
You cannot "combine" two templates in one document -- Word doesn't work that
way.

Why do you say the source document cannot be altered? Is it locked in some way?
If not, you certainly can add information, as long as you don't change what's
already there.

There are various ways to do that, using the Replace dialog or a macro. But to
make a specific recommendation, I need to know _exactly_ what the source
document looks like and what you want in the final document. Don't omit any
text, just explain what changes from one source document to another. Also, give
at least three groups of information, not just two (it could make a difference).
 
Jay Freedman said:
You cannot "combine" two templates in one document -- Word doesn't work that
way.

Why do you say the source document cannot be altered? Is it locked in some way?
If not, you certainly can add information, as long as you don't change what's
already there.

There are various ways to do that, using the Replace dialog or a macro. But to
make a specific recommendation, I need to know _exactly_ what the source
document looks like and what you want in the final document. Don't omit any
text, just explain what changes from one source document to another. Also, give
at least three groups of information, not just two (it could make a difference).



--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
 
P.S. Sorry I forgot - two pieces of information changes: the numbers after
the Z and the PIN number. Since each internet sign up is specifically for
that person only, the numbers have to change with the next person.
 
You are still not answering the question. We cannot see your document. What
does the document look like when you receive it, and what do you want it to
look like when you have finished with it. What is the aim of the exercise
and where are the variable numbers and pin numbers created. Do you in fact
want a facility to put 20 entries on a sheet in the format -

Identifier:
Z8082422838
PIN|: 0882
Patron Type: Sign up for a library card now

Identifier:
Z8082422839
PIN|: 0993
Patron Type: Sign up for a library card now

that will generate the two numbers and type in the fixed text, or do you
have the two numbers and wish to add the fixed text? Is the fixed text fixed
for each entry?

Tell us EXACTLY what you are doing and remove the guesswork!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Graham Mayor said:
You are still not answering the question. We cannot see your document. What
does the document look like when you receive it, and what do you want it to
look like when you have finished with it. What is the aim of the exercise
and where are the variable numbers and pin numbers created. Do you in fact
want a facility to put 20 entries on a sheet in the format -

Identifier:
Z8082422838
Patron Type: Sign up for a library card now

Identifier:
Z8082422839
Patron Type: Sign up for a library card now

that will generate the two numbers and type in the fixed text, or do you
have the two numbers and wish to add the fixed text? Is the fixed text fixed
for each entry?

Tell us EXACTLY what you are doing and remove the guesswork!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
I believe I have posted the document I'm working from - it is several sets of
numbers, an example below. This the source document. The source document
does not have the following: Sign up for a library card now. The destination
target has it. I need to insert the new sequential numbers from the source
document to the destination target that has the sentence. However, after
hours of trial and error, I believe I came up with the answer. I'll know
Tuesday when I go back to work whether it works or not. Right now it works,
but I don't have access to the program that generates these numbers. I'm
working from a flash drive that I used to download the numbers originally
from the software at work. I just made a template in Excell with the
appropriate spacing of rows and columns with the sentence that needs to be
added typed in, leaving room to paste any new sets of numbers. Then all I
did was copy and paste. Hopefully, it will work. I want to thank you both
for all the time and effort you gave to help me. Sorry if I didn't make it
clear. I thought I did, but maybe not. Thanks again, Glory

Identifier:
 
If the document is as you described it, you are making a mountain out of a
molehill. I asked for more detail as it seemed likely that there was more to
it. Simply use the replace function CTRL+H to find.

Patron Type:
and replace with
Patron Type: Sign up for a library card now
then SaveAs with a new name.


The following macro will essentially do that.

Sub EditMyDoc()
'open the document containing the new entries
'and run the macro
Dim SourceDoc As Document
Dim TargetDoc As Document
'define the active document as the source
Set SourceDoc = ActiveDocument
'open a new document to accept the changes
Set TargetDoc = Documents.Add
SourceDoc.Activate
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
'Find the Patron Type entry line
.Text = "Patron Type:"
'Replace it with the following
.Replacement.Text = "Patron Type: Sign up for a library card now"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
' If Identifier: is on a separate line and needs to
' be on the same line as the following number
' Remove the "'" from the start of the next three lines
' .Text = "Identifier:^p"
' .Replacement.Text = "Identifier:"
' .Execute Replace:=wdReplaceAll
End With
Selection.WholeStory 'select the edited document
Selection.Copy 'and copy to the clipboard
TargetDoc.Activate ' open the new document
Selection.Paste ' and paste in the clipboard content
'close the original document without the changes
SourceDoc.Close SaveChanges:=wdDoNotSaveChanges
'Save the new document
TargetDoc.Save
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top