I use VBA to create an overlapping character in Word:
a = "x"
b = "."
Selection.Fields.Add Range:=Selection.Range, Text:= _
"EQ \o (" & a & "," & b & ")", PreserveFormatting:=False
The output is
{ EQ \o (x,.) }
which produces: http://img843.imageshack.us/img843/3783/1849213开发者_高级运维3.png. As can be seen by the gray box, the character is to wide. The width can be reduced to http://img838.imageshack.us/img838/1723/69344761.png by changing the field manually to
{ EQ \o (x,.)} or {EQ \o (x,.)}
But how can this be achieved directly in VBA?
My assumption is you need to remove the trailing space between the final paranthesis and curly bracket.
Dim x As String
Dim y As String
x = "{ EQ \o (x,.) }"
y = Replace(x, " }", "}") 'Note the space for the find expression e.g. ' }' 'Could also put ") }" replace with ")}"
y becomes the output I think you desire
You can just use the replace function shown above to accomplish this task.
Your code would become
a = "x"
b = "."
Selection.Fields.Add Range:=Selection.Range, Text:= _
"EQ \o (" & a & "," & b & ")", PreserveFormatting:=False
Selection.Range.Text = Replace(Selection.Range.Text, ") }", ")}")
This code assign correct value to field EQ
ActiveDocument.Fields.Item(numderfield).Code.Text = "EQ \o (" & a & "," & b & ")"
精彩评论