H
Holger Kreißl
Question to VBA and Word >= 2000
Hi,
i want to write an rewrite values of textfields.
word example: {field1} {field2} {field3}
I figured out, that I can get the fieldnames in that way:
int_count = ActiveDocument.Fields.Count
For iterator = 1 To int_count
Code = ActiveDocument.Fields.Item(iterator).Code
com = InStr(Code, updatestring)
If (com > 0) Then
iFieldIndex = iterator
Exit For
End If
Next iterator
(Is there a way to reference the field directly with the fieldname? Without
iterating all fields?)
So I get the object of that field an try to overwrite the field content. I
do that in this way:
ActiveDocument.Fields.Item(iFieldIndex).Result.Text = value
But it doesn't work in that way I want. That command does not overwrite the
old value. It writes the text at the end of the existing text :-/
Is my way the wrong way to change the value of a textfield? Maybe does
somebody have an better example or some ideas
thank you,
Holger
Hi,
i want to write an rewrite values of textfields.
word example: {field1} {field2} {field3}
I figured out, that I can get the fieldnames in that way:
int_count = ActiveDocument.Fields.Count
For iterator = 1 To int_count
Code = ActiveDocument.Fields.Item(iterator).Code
com = InStr(Code, updatestring)
If (com > 0) Then
iFieldIndex = iterator
Exit For
End If
Next iterator
(Is there a way to reference the field directly with the fieldname? Without
iterating all fields?)
So I get the object of that field an try to overwrite the field content. I
do that in this way:
ActiveDocument.Fields.Item(iFieldIndex).Result.Text = value
But it doesn't work in that way I want. That command does not overwrite the
old value. It writes the text at the end of the existing text :-/
Is my way the wrong way to change the value of a textfield? Maybe does
somebody have an better example or some ideas
thank you,
Holger