View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default A 'teachable' way to apply percentage formatting

The { MERGEFIELD } field needs to be nested inside a {=} field that does
the multiplication, e.g.

{ = { MERGEFIELD On_Time } * 100 \#0.0% }

where each pair of {} must be the special field braces that you can
insert using ctrl-F9

Peter Jamieson

http://tips.pjmsn.me.uk

todd wrote:
No matter what I do, I can't get the % thing to work. Here's my current code:
{ MERGEFIELD "On_Time"*100\# "0.0%"}
and it does not show the proper percent. It shows 0.8% instead of 80.0%.
What in the world am I doing wrong? I have tried several variations of this.
When I changed my code to the MERGEFIELD "On_Time" part in the {}, I get no
result.

Does this only work on certain versions of Word? I use Word 2003 SP3.

Any help would be greatly appreciated.

thanks,
todd


"Doug Robbins - Word MVP" wrote:

If you added a button to a toolbar to run a macro that contains the
following code, if the selection is in a mergefield when that button is
clicked, it will make the necessary modification to the mergefield so that
the result will be displayed in the format #%

Dim mfield As Range
Dim fieldname As String
Selection.Words(1).Select
Selection.MoveStart wdCharacter, -1
Set mfield = Selection.Range.Fields(1).Code
If InStr(UCase(mfield), "MERGEFIELD") 0 Then
Selection.Cut
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, "=" &
mfield.Text & " * 100 \# 0%"
End If
Selection.Words(1).Select
Set mfield = Selection.Fields(1).Code.Duplicate
mfield.Collapse wdCollapseStart
mfield.Move wdCharacter, 2
mfield.Paste
Selection.Range.Fields.Update


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"David Powell" wrote in message
news
I found I could use the following to apply percentages formatted in Excel
or
Access in a Word mailmerge:

{ = MERGEFIELD "Fieldname" } * 100 \# "00%" },

where the braces are the 'magic' inserted by Ctrl-F9, and "Fieldname" is
the
field.
(From looking at other posts here, it seems I could omit one of the zeroes
in the format string above.)

Now: how can I encapsulate or package this incantation somehow, so that
others have a chance of applying it into their mail merges?
I can't get Autotext to work for me.