J
jsouriane
In Word, I wish to create the following macro and it doesn’t work:
Before using the macro, I merge a document. There is a place where I
bookmarked a field, so once the merge done, the bookmark is still
there.
I want the macro to go get the words in the bookmark, copy it, open a
Document (Name Known) and search for the copied words.
Once it has found the words, my macro will continue with something
else but I am just not able to get there. Can you help me someone?
Thank you!!
HERE is that part of the macro so far:
Selection.InsertCrossReference ReferenceType:="Signet",
ReferenceKind:= _
wdContentText, ReferenceItem:="NAME_OF_MY_BOOKMARK",
InsertAsHyperlink:=False, _
IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Dim CopiedWord
CopiedWord = Selection.Text
'Opens the Second document where to search in:
Documents.Open FileName:="""c:\temp\Document.doc"""
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = CopiedWord
End With
Selection.Find.Execute
Before using the macro, I merge a document. There is a place where I
bookmarked a field, so once the merge done, the bookmark is still
there.
I want the macro to go get the words in the bookmark, copy it, open a
Document (Name Known) and search for the copied words.
Once it has found the words, my macro will continue with something
else but I am just not able to get there. Can you help me someone?
Thank you!!
HERE is that part of the macro so far:
Selection.InsertCrossReference ReferenceType:="Signet",
ReferenceKind:= _
wdContentText, ReferenceItem:="NAME_OF_MY_BOOKMARK",
InsertAsHyperlink:=False, _
IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Dim CopiedWord
CopiedWord = Selection.Text
'Opens the Second document where to search in:
Documents.Open FileName:="""c:\temp\Document.doc"""
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = CopiedWord
End With
Selection.Find.Execute