F
Fogharty
I am working with a large group of documents that have questions and
answers in them. The answers are using red text, everything else is in
black. I would like to create a macro that will search the active
document, find the first paragraph of red text, copy it, go to a
second document titled "Answer keys" and paste the text in there.
So far so good.
But then I would like to go back to the first document, and find the
NEXT paragraph of red text, copy, go to "Answer keys.doc", paste, go
back to original document, etc. until there is no more new red text to
be found. The macro I recorded specifies the name of the first
document "0101 Lesson 1" but I would like the macro to be more generic
than that... to go to the other document that is NOT "Answer keys" to
find the text, copy, and so on.
How is this to be done? So that the macro will go back to the first
document, find the next paragraph of red text, copy, and so forth.
When I recorded a macro, it kept copying the same text over and over,
and of course, the document name will change on the next file.
This is what I recorded:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
Windows("Answer keys.doc").Activate
Application.Run MacroName:="MathTypeCommands.UIWrappers.EditPaste"
Windows("0101 Lesson 1.doc").Activate
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
Windows("Answer keys.doc").Activate
With ActiveWindow
.Left = 764
.Top = 36
End With
Application.Run MacroName:="MathTypeCommands.UIWrappers.EditPaste"
Windows("0101 Lesson 1.doc").Activate
With ActiveWindow
.Left = 8
.Top = 7
End With
End Sub
Eventually this macro will be shared with Word 2007 users, and I'll
have to come up with something to make it work in Word 2008 (perhaps
an Applescript of some kind.)
answers in them. The answers are using red text, everything else is in
black. I would like to create a macro that will search the active
document, find the first paragraph of red text, copy it, go to a
second document titled "Answer keys" and paste the text in there.
So far so good.
But then I would like to go back to the first document, and find the
NEXT paragraph of red text, copy, go to "Answer keys.doc", paste, go
back to original document, etc. until there is no more new red text to
be found. The macro I recorded specifies the name of the first
document "0101 Lesson 1" but I would like the macro to be more generic
than that... to go to the other document that is NOT "Answer keys" to
find the text, copy, and so on.
How is this to be done? So that the macro will go back to the first
document, find the next paragraph of red text, copy, and so forth.
When I recorded a macro, it kept copying the same text over and over,
and of course, the document name will change on the next file.
This is what I recorded:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
Windows("Answer keys.doc").Activate
Application.Run MacroName:="MathTypeCommands.UIWrappers.EditPaste"
Windows("0101 Lesson 1.doc").Activate
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
Windows("Answer keys.doc").Activate
With ActiveWindow
.Left = 764
.Top = 36
End With
Application.Run MacroName:="MathTypeCommands.UIWrappers.EditPaste"
Windows("0101 Lesson 1.doc").Activate
With ActiveWindow
.Left = 8
.Top = 7
End With
End Sub
Eventually this macro will be shared with Word 2007 users, and I'll
have to come up with something to make it work in Word 2008 (perhaps
an Applescript of some kind.)