C
CatMarieS
I have been trying to make a simple macro so that I can copy certain field
codes from a document and paste them by themselves into a new document so I
can look at them. When I record the macro, things work out fine as I do
them: I first search to highlight the term "^d SET" (the SET is part of the
code I want) then copy and paste it into a new document. It works fine when
I do it, but the macro doesn't want to run. Here's the macro:
Sub Macro1()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^d SET"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Copy
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
End Sub
I've been doing some research and it appears that the problem is that I need
to use "expression" in the place of "selection", but merely replacing the
term doesn't help.
In another approach to the problem - is there a way to convert field codes
into plain text? If I did that, then I wouldn't need to worry about
selection expressions vs. selecting normal text.
codes from a document and paste them by themselves into a new document so I
can look at them. When I record the macro, things work out fine as I do
them: I first search to highlight the term "^d SET" (the SET is part of the
code I want) then copy and paste it into a new document. It works fine when
I do it, but the macro doesn't want to run. Here's the macro:
Sub Macro1()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^d SET"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Copy
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
End Sub
I've been doing some research and it appears that the problem is that I need
to use "expression" in the place of "selection", but merely replacing the
term doesn't help.
In another approach to the problem - is there a way to convert field codes
into plain text? If I did that, then I wouldn't need to worry about
selection expressions vs. selecting normal text.