B
Bob S
What is a good way to delete the final character (a space character)
in a field? Word 2002 SP2
What I have been trying is
Set rngWork = Selection.Range
Set fldWork = ActiveDocument.Fields.Add(Range:=Selection.Range,
Type:=wdFieldEmpty, PreserveFormatting:=False)
rngWork.Select
' this lets me check the selection; it seem to be selecting the whole
' field including the braces
' there is an extra space character at each end of the field contents,
' because an empty field actually contains two space characters
Selection.Range.Characters(2).Delete
' this line successfully deletes the leading space
' This next line crashed Word hard
Selection.Range.Characters(Selection.Range.Characters.Count -
1).Delete
When run in a macro that last line crashes Word completely (please
send a report, recovering the documents, etc.).
When run in the immediate window it doesn't crash, but doesn't delete
the space (or anything else) either! If I use 2 instead of 1, it
successfully deletes the character before the space.
Bob S
in a field? Word 2002 SP2
What I have been trying is
Set rngWork = Selection.Range
Set fldWork = ActiveDocument.Fields.Add(Range:=Selection.Range,
Type:=wdFieldEmpty, PreserveFormatting:=False)
rngWork.Select
' this lets me check the selection; it seem to be selecting the whole
' field including the braces
' there is an extra space character at each end of the field contents,
' because an empty field actually contains two space characters
Selection.Range.Characters(2).Delete
' this line successfully deletes the leading space
' This next line crashed Word hard
Selection.Range.Characters(Selection.Range.Characters.Count -
1).Delete
When run in a macro that last line crashes Word completely (please
send a report, recovering the documents, etc.).
When run in the immediate window it doesn't crash, but doesn't delete
the space (or anything else) either! If I use 2 instead of 1, it
successfully deletes the character before the space.
Bob S