M
MattW
I have documents with field codes and I need to find/select the field codes
based on thier name and then replace with plain text.
I can't seem to find any documentation on how to select a field code... I
won't be able to specify the exact name for the field code. The documents I
am working with may have the same field code as { OrdClosingDate_1_4_0 } or
{ OrdClosingDate_2_4_0 } or { OrdClosingDate_3_4_0 } etc, and I will need to
find them by specifying "OrdClosingDate" and replace (all matching
occurances with a text string from a variable that I retrieved from an SQL
server... The field code should be deleted in the process.
Any insight on this would be greatly appreciated. I am currently using the
code below to find/replace, so maybe i just need to know what to specify for
'TagToReplace'
Thanks, Matt
___________________________________________________
Function InsertData(TagToReplace, DataToInsert)
If DataToInsert = "" Then
Exit Function
End If
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = TagToReplace
.Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
End With
Do Until Selection.Find.Execute = False ' Start Loop
Selection.Find.ClearFormatting
With Selection.Find
.Text = TagToReplace
.Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
End With
Selection.TypeText Text:=DataToInsert ' ParagraphNumber & "."
If DataToInsert = " " Then Selection.TypeBackspace
Loop
End Function
based on thier name and then replace with plain text.
I can't seem to find any documentation on how to select a field code... I
won't be able to specify the exact name for the field code. The documents I
am working with may have the same field code as { OrdClosingDate_1_4_0 } or
{ OrdClosingDate_2_4_0 } or { OrdClosingDate_3_4_0 } etc, and I will need to
find them by specifying "OrdClosingDate" and replace (all matching
occurances with a text string from a variable that I retrieved from an SQL
server... The field code should be deleted in the process.
Any insight on this would be greatly appreciated. I am currently using the
code below to find/replace, so maybe i just need to know what to specify for
'TagToReplace'
Thanks, Matt
___________________________________________________
Function InsertData(TagToReplace, DataToInsert)
If DataToInsert = "" Then
Exit Function
End If
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = TagToReplace
.Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
End With
Do Until Selection.Find.Execute = False ' Start Loop
Selection.Find.ClearFormatting
With Selection.Find
.Text = TagToReplace
.Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
End With
Selection.TypeText Text:=DataToInsert ' ParagraphNumber & "."
If DataToInsert = " " Then Selection.TypeBackspace
Loop
End Function