K
KSH
Is it possible to remove one of the fields in the word document that you are
replacing data in.
For example:
{Name}
{address line 1}
{address line 2}
All the people in my list will not have 2 lines of address. I either want
to delete the 2 in those cases. Or set up the word doc to only have one line
and do an insert if I need to, but I can't figure out how to code that. Here
is my code where I try to inser:
Do While Not rsdocfields.EOF
'''' Read through fields for this document and replace
varreplacewith = RS.Fields(rsdocfields!replacewithfield)
With docword.Content.Find
With .Replacement
''' additional formating here if needed
' .ClearFormatting
End With
.Execute findtext:=rsdocfields!docfieldtag,
replacewith:=varreplacewith
End With
If RS.Fields(rsdocfields!replacewithfield) = "Address Line
2" Then
If varreplacewith <> "N/A" Then
With docword.Content
.InsertAfter (varreplacewith)
.InsertAfter vbCrLf
.Collapse
End With
End If
End If
rsdocfields.MoveNext
Loop
Working in Automation is new for me, so I know what I want to do, just can't
always figure out the code to do it. Thanks for any help.
replacing data in.
For example:
{Name}
{address line 1}
{address line 2}
All the people in my list will not have 2 lines of address. I either want
to delete the 2 in those cases. Or set up the word doc to only have one line
and do an insert if I need to, but I can't figure out how to code that. Here
is my code where I try to inser:
Do While Not rsdocfields.EOF
'''' Read through fields for this document and replace
varreplacewith = RS.Fields(rsdocfields!replacewithfield)
With docword.Content.Find
With .Replacement
''' additional formating here if needed
' .ClearFormatting
End With
.Execute findtext:=rsdocfields!docfieldtag,
replacewith:=varreplacewith
End With
If RS.Fields(rsdocfields!replacewithfield) = "Address Line
2" Then
If varreplacewith <> "N/A" Then
With docword.Content
.InsertAfter (varreplacewith)
.InsertAfter vbCrLf
.Collapse
End With
End If
End If
rsdocfields.MoveNext
Loop
Working in Automation is new for me, so I know what I want to do, just can't
always figure out the code to do it. Thanks for any help.