Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
lauralee08 lauralee08 is offline
external usenet poster
 
Posts: 6
Default Percent formatted field makes me enter as .10

I have my form field set up as a percent, in Excel I am used to just entering
"10", and it will convert to "10%" or "10.00%", but Word is changing that
same entry to "1000%". It makes me enter as ".10", which is just stupid that
I have to do that only in Word and nowhere else. Does anyone know a way to
change this so I can enter 10 and get 10%?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Percent formatted field makes me enter as .10

If you want to enter 10 and have it display as 10% you are going to need
perform a calculation on that field which will need vba. The following macro
run on exit from the form field in question (which should be set as text
type) will allow you to enter 10 to produce 10% and 10.5 to produce 10.5%
etc. when you tab out of that field. The macro assumes the field is
bookmarked Text1

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub= Format(sRes / 100, "###.00%")
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


lauralee08 wrote:
I have my form field set up as a percent, in Excel I am used to just
entering "10", and it will convert to "10%" or "10.00%", but Word is
changing that same entry to "1000%". It makes me enter as ".10",
which is just stupid that I have to do that only in Word and nowhere
else. Does anyone know a way to change this so I can enter 10 and
get 10%?



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Lenny Lenny is offline
external usenet poster
 
Posts: 74
Default Percent formatted field makes me enter as .10

Lenny he
Graham - I too have the same problem, however, when I copied your code into
my module, I started getting errors when trying to run the code. It did not
like the second to last End Sub= statement (indicating it could only be used
with comments), when I deleted it and ran the code, it did not care for the
If sRes = Int(sres) ... at that point, I thought I would come back to the
source. I am running Word 2003. Regards

"Graham Mayor" wrote:

If you want to enter 10 and have it display as 10% you are going to need
perform a calculation on that field which will need vba. The following macro
run on exit from the form field in question (which should be set as text
type) will allow you to enter 10 to produce 10% and 10.5 to produce 10.5%
etc. when you tab out of that field. The macro assumes the field is
bookmarked Text1

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub= Format(sRes / 100, "###.00%")
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


lauralee08 wrote:
I have my form field set up as a percent, in Excel I am used to just
entering "10", and it will convert to "10%" or "10.00%", but Word is
changing that same entry to "1000%". It makes me enter as ".10",
which is just stupid that I have to do that only in Word and nowhere
else. Does anyone know a way to change this so I can enter 10 and
get 10%?




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Percent formatted field makes me enter as .10

I am not surprised it didn't work - something odd happened there during the
transcribing of the code

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = Replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub

is what it should have been. Apologies )


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Lenny wrote:
Lenny he
Graham - I too have the same problem, however, when I copied your
code into my module, I started getting errors when trying to run the
code. It did not like the second to last End Sub= statement
(indicating it could only be used with comments), when I deleted it
and ran the code, it did not care for the If sRes = Int(sres) ... at
that point, I thought I would come back to the source. I am running
Word 2003. Regards

"Graham Mayor" wrote:

If you want to enter 10 and have it display as 10% you are going to
need perform a calculation on that field which will need vba. The
following macro run on exit from the form field in question (which
should be set as text type) will allow you to enter 10 to produce
10% and 10.5 to produce 10.5% etc. when you tab out of that field.
The macro assumes the field is bookmarked Text1

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub= Format(sRes / 100, "###.00%")
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


lauralee08 wrote:
I have my form field set up as a percent, in Excel I am used to just
entering "10", and it will convert to "10%" or "10.00%", but Word is
changing that same entry to "1000%". It makes me enter as ".10",
which is just stupid that I have to do that only in Word and nowhere
else. Does anyone know a way to change this so I can enter 10 and
get 10%?



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Lenny Lenny is offline
external usenet poster
 
Posts: 74
Default Percent formatted field makes me enter as .10

Graham: the revised code worked perfectly... a question though. When
tabbing from another form field, into the "text1" field, everythings fine as
long as you actually enter a number and tab out. If you try to tab thru the
field (not entering a number) you get a "run time error (13)". Can this be
corrected? Lenny

"Graham Mayor" wrote:

I am not surprised it didn't work - something odd happened there during the
transcribing of the code

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = Replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub

is what it should have been. Apologies )


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Lenny wrote:
Lenny he
Graham - I too have the same problem, however, when I copied your
code into my module, I started getting errors when trying to run the
code. It did not like the second to last End Sub= statement
(indicating it could only be used with comments), when I deleted it
and ran the code, it did not care for the If sRes = Int(sres) ... at
that point, I thought I would come back to the source. I am running
Word 2003. Regards

"Graham Mayor" wrote:

If you want to enter 10 and have it display as 10% you are going to
need perform a calculation on that field which will need vba. The
following macro run on exit from the form field in question (which
should be set as text type) will allow you to enter 10 to produce
10% and 10.5 to produce 10.5% etc. when you tab out of that field.
The macro assumes the field is bookmarked Text1

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub= Format(sRes / 100, "###.00%")
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


lauralee08 wrote:
I have my form field set up as a percent, in Excel I am used to just
entering "10", and it will convert to "10%" or "10.00%", but Word is
changing that same entry to "1000%". It makes me enter as ".10",
which is just stupid that I have to do that only in Word and nowhere
else. Does anyone know a way to change this so I can enter 10 and
get 10%?






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Percent formatted field makes me enter as .10

Immediately after the line sRes = oFld("Text1").Result, add this line:

If Len(sRes) = 0 Then Exit Sub

If you would rather have 0 appear in the field when you tab through it, use
this line instead:

If Len(sRes) = 0 Then sRes = "0"


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Lenny wrote:
Graham: the revised code worked perfectly... a question though. When
tabbing from another form field, into the "text1" field, everythings
fine as long as you actually enter a number and tab out. If you try
to tab thru the field (not entering a number) you get a "run time
error (13)". Can this be corrected? Lenny

"Graham Mayor" wrote:

I am not surprised it didn't work - something odd happened there
during the transcribing of the code

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = Replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub

is what it should have been. Apologies )


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Lenny wrote:
Lenny he
Graham - I too have the same problem, however, when I copied your
code into my module, I started getting errors when trying to run the
code. It did not like the second to last End Sub= statement
(indicating it could only be used with comments), when I deleted it
and ran the code, it did not care for the If sRes = Int(sres) ...
at that point, I thought I would come back to the source. I am
running Word 2003. Regards

"Graham Mayor" wrote:

If you want to enter 10 and have it display as 10% you are going to
need perform a calculation on that field which will need vba. The
following macro run on exit from the form field in question (which
should be set as text type) will allow you to enter 10 to produce
10% and 10.5 to produce 10.5% etc. when you tab out of that field.
The macro assumes the field is bookmarked Text1

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub= Format(sRes / 100, "###.00%")
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


lauralee08 wrote:
I have my form field set up as a percent, in Excel I am used to
just entering "10", and it will convert to "10%" or "10.00%", but
Word is changing that same entry to "1000%". It makes me enter
as ".10", which is just stupid that I have to do that only in
Word and nowhere else. Does anyone know a way to change this so
I can enter 10 and get 10%?



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Lenny Lenny is offline
external usenet poster
 
Posts: 74
Default Percent formatted field makes me enter as .10

Jay: works like a charm! regards, Lenny

"Jay Freedman" wrote:

Immediately after the line sRes = oFld("Text1").Result, add this line:

If Len(sRes) = 0 Then Exit Sub

If you would rather have 0 appear in the field when you tab through it, use
this line instead:

If Len(sRes) = 0 Then sRes = "0"


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Lenny wrote:
Graham: the revised code worked perfectly... a question though. When
tabbing from another form field, into the "text1" field, everythings
fine as long as you actually enter a number and tab out. If you try
to tab thru the field (not entering a number) you get a "run time
error (13)". Can this be corrected? Lenny

"Graham Mayor" wrote:

I am not surprised it didn't work - something odd happened there
during the transcribing of the code

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = Replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub

is what it should have been. Apologies )


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Lenny wrote:
Lenny he
Graham - I too have the same problem, however, when I copied your
code into my module, I started getting errors when trying to run the
code. It did not like the second to last End Sub= statement
(indicating it could only be used with comments), when I deleted it
and ran the code, it did not care for the If sRes = Int(sres) ...
at that point, I thought I would come back to the source. I am
running Word 2003. Regards

"Graham Mayor" wrote:

If you want to enter 10 and have it display as 10% you are going to
need perform a calculation on that field which will need vba. The
following macro run on exit from the form field in question (which
should be set as text type) will allow you to enter 10 to produce
10% and 10.5 to produce 10.5% etc. when you tab out of that field.
The macro assumes the field is bookmarked Text1

Sub Percentage()
Dim oFld As FormFields
Dim sRes As String
Dim sDec As String
Set oFld = ActiveDocument.FormFields
sRes = oFld("Text1").Result
If InStr(1, sRes, "%") Then
sRes = replace(sRes, "%", "")
End If
If sRes = Int(sRes) Then
sDec = "###%"
Else
sDec = "###.##%"
End If
oFld("Text1").Result = Format(sRes / 100, sDec)
End Sub= Format(sRes / 100, "###.00%")
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


lauralee08 wrote:
I have my form field set up as a percent, in Excel I am used to
just entering "10", and it will convert to "10%" or "10.00%", but
Word is changing that same entry to "1000%". It makes me enter
as ".10", which is just stupid that I have to do that only in
Word and nowhere else. Does anyone know a way to change this so
I can enter 10 and get 10%?




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2007: Set for Double Space, but Enter makes 2.5 spaces GeekBoy Page Layout 2 December 5th 07 10:54 PM
rtf formatted Memo field from Access 07 Mailmerge into Word Lara Mailmerge 3 October 23rd 07 08:56 PM
How do I create a form field to contain formatted text cucubit Microsoft Word Help 2 March 10th 06 02:24 PM
Is there a way to type formatted text into a form field? AaronTram Microsoft Word Help 1 November 6th 05 10:27 PM
formatting percent field using mail merge PamWilhite Mailmerge 3 February 19th 05 08:58 AM


All times are GMT +1. The time now is 06:34 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"