Scotsman71
Programmer
I've been working on a macro(I've posted about it before) for MS Word, so that if I key in a friends name at a prompt, it will go into a text file, find his name and address and paste it for me. I'm ALMOST there 
The macro is below. The problem with it is this part:
With Selection.Find
.Text = "Michael Smith"
You see, instead of putting the text Michael Smith there, it has to paste the clipboard. So I am doing a find, and I want it to paste the clipboard text in there. How would I do that?
Selection.HomeKey Unit:=wdLine
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Friend:"
.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:=3
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:="address.txt", ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto, Encoding:=1252
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Michael Smith"
.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:=2
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=5, Extend:=wdExtend
Selection.Copy
ActiveWindow.Close
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.PasteAndFormat (wdPasteDefault)
The macro is below. The problem with it is this part:
With Selection.Find
.Text = "Michael Smith"
You see, instead of putting the text Michael Smith there, it has to paste the clipboard. So I am doing a find, and I want it to paste the clipboard text in there. How would I do that?
Selection.HomeKey Unit:=wdLine
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Friend:"
.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:=3
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:="address.txt", ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto, Encoding:=1252
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Michael Smith"
.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:=2
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=5, Extend:=wdExtend
Selection.Copy
ActiveWindow.Close
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.PasteAndFormat (wdPasteDefault)