Hi Dave
I get the first macro to open a template called memo which contains
bookmarks with merge codes. In this macro the user simply fills in the
form, using F11 to go from place to place between the bookmarks and saves
the file. Then 4 macros follow, each macro opens a template (with the memo
still open) and then switches backward and forward copying between the
bookmarks in the memo and going to words or + signs and then pasting in the
information from the memo to the letter. It also expands some autotext at
the bottom of the document. I have put an example of the mem macro and one
of the letter macros below. This has worked well in the past and now it has
started throwing up error messages such as "entered multiple destination
from a footnote, endnote or comment". I would be so grateful for some help
because I have recoreded it and rerecorded it so many times I am tearing my
hair out. Thanks so much.
Margaret
This is the first mem macro
Sub mem()
'
' mem Macro
' Macro recorded 3/02/04 by Margaret Upton
'
Documents.add Template:= _
"C:\WINDOWS\Application Data\Microsoft\Templates\Letters\memo.dot",
_
NewTemplate:=False, DocumentType:=0
Selection.NextField.Select
Application.Run MacroName:="Textoff"
With Dialogs(wdDialogFileSaveAs)
.Name = "C:\My Documents\Memos\"
.Show
End With
End Sub
THIS IS THE OTHER MACRO
' vs Macro
' Macro recorded 3/02/04 by Margaret Upton
'
Documents.add Template:= _
"C:\WINDOWS\Application Data\Microsoft\Templates\Letters\Vendors
sols letter.dot" _
, NewTemplate:=False, DocumentType:=0
Windows(2).Activate
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.copy
Windows(1).Activate
Selection.EndKey Unit:=wdLine
Selection.paste
Windows(2).Activate
Selection.GoTo What:=wdGoToBookmark, Name:="vens"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Re:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Extend
Selection.GoTo What:=wdGoToBookmark, Name:="vens2"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Re:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.copy
Windows(1).Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "for the attention of"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine
Application.Run MacroName:="Normal.NewMacros.pastesimple"
Windows(2).Activate
Selection.GoTo What:=wdGoToBookmark, Name:="add"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "for the attention of"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Extend
Selection.GoTo What:=wdGoToBookmark, Name:="add2"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "for the attention of"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.copy
Windows(1).Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Re:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine
Application.Run MacroName:="Normal.NewMacros.pastesimple"
Windows(2).Activate
Selection.GoTo What:=wdGoToBookmark, Name:="ven"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Re:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Extend
Selection.GoTo What:=wdGoToBookmark, Name:="ven2"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Re:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.copy
Windows(1).Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "+"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Application.Run MacroName:="Normal.NewMacros.pastesimple"
Windows(2).Activate
Selection.GoTo What:=wdGoToBookmark, Name:="pur"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "+"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Extend
Selection.GoTo What:=wdGoToBookmark, Name:="pur2"
Selection.Find.ClearFormatting
With Selection.Find
.Text = "+"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.copy
Windows(1).Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "++"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Application.Run MacroName:="Normal.NewMacros.pastesimple"
Windows(2).Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "/"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
Selection.copy
Windows(1).Activate
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "miller evans"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.paste
Selection.Range.InsertAutoText
Selection.HomeKey Unit:=wdStory
Selection.NextField.Select
Selection.NextField.Select
End Sub
Dave Lett said:
Hi Margaret,
Yes, someone here can probably help. However, it will most likely require
that you abandon the recorded marco. In a list, can you tell us what you
want (what you start with and what you want to end up with)? Are both
documents open? Do their file names change?
I assume that you want to
1) identify text or graphics in DocA, BookmarkA
2) copy that text to DocB, BookmarkB
3) close? save?
4) repeat the procedure a number of times (is so, what is repeating and
what is not; that is, have the names of the bookmarks or the names of either
document changed?)