Reply
 
Thread Tools Display Modes
  #1   Report Post  
Darryl
 
Posts: n/a
Default cell formatting

Greetings,
I have a table in my word document. One of the cells is numeric in format.
I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to 870%. I want
it to be 8.7%.

How do I do this ? Do I have to create a macro that mathematically converts
it ?

thanks,
-Darryl


  #2   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is numeric in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to 870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that mathematically
converts it ?


Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #3   Report Post  
Darryl
 
Posts: n/a
Default

Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is numeric in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to 870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that mathematically
converts it ?


Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





  #4   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

In addition to adding a number format, you'll have to do some math to divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is numeric in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to 870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that mathematically
converts it ?


Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org






  #5   Report Post  
Darryl
 
Posts: n/a
Default

OK then.
How can I create a macro to divide the cell contents (that I am exiting) by
100 ?

thanks,
Darryl
"Suzanne S. Barnhill" wrote in message
...
In addition to adding a number format, you'll have to do some math to

divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup

so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is numeric in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to 870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that mathematically
converts it ?

Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org










  #6   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

No macro needed. The fact that you have already applied a number format
suggests that you're using a field. If it's an = field or (as sounds more
likely) a calculated form field, all you have to do is add /100 to the
calculation.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Darryl" wrote in message
...
OK then.
How can I create a macro to divide the cell contents (that I am exiting)

by
100 ?

thanks,
Darryl
"Suzanne S. Barnhill" wrote in message
...
In addition to adding a number format, you'll have to do some math to

divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is numeric

in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to 870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that

mathematically
converts it ?

Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org









  #7   Report Post  
Darryl
 
Posts: n/a
Default

It's not calculated. The user types in the value. The formatting was to
get it a percentage.
So, the user types in 8.7 and the formatting changes it to 8.7%.


"Suzanne S. Barnhill" wrote in message
...
No macro needed. The fact that you have already applied a number format
suggests that you're using a field. If it's an = field or (as sounds more
likely) a calculated form field, all you have to do is add /100 to the
calculation.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup

so
all may benefit.

"Darryl" wrote in message
...
OK then.
How can I create a macro to divide the cell contents (that I am exiting)

by
100 ?

thanks,
Darryl
"Suzanne S. Barnhill" wrote in message
...
In addition to adding a number format, you'll have to do some math to

divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is

numeric
in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to

870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that

mathematically
converts it ?

Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org











  #8   Report Post  
Anne Troy
 
Posts: n/a
Default

Hi, Darryl. The whole confusion about percentage formatting is that 8.7 is
not 8.7%. 8.7 percent formatted as a decimal is really 0.087, so that needs
to be entered, or you need to divide it by 100 so it works the way you want
it to. This also confuses Excel users.
*******************
~Anne Troy

www.OfficeArticles.com


"Darryl" wrote in message
...
It's not calculated. The user types in the value. The formatting was to
get it a percentage.
So, the user types in 8.7 and the formatting changes it to 8.7%.


"Suzanne S. Barnhill" wrote in message
...
No macro needed. The fact that you have already applied a number format
suggests that you're using a field. If it's an = field or (as sounds

more
likely) a calculated form field, all you have to do is add /100 to the
calculation.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
OK then.
How can I create a macro to divide the cell contents (that I am

exiting)
by
100 ?

thanks,
Darryl
"Suzanne S. Barnhill" wrote in message
...
In addition to adding a number format, you'll have to do some math

to
divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is

numeric
in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to

870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that

mathematically
converts it ?

Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org













  #9   Report Post  
Darryl
 
Posts: n/a
Default

Thanks Anne.

I understand that 8.7 is not 8.7%. But as the users say, I need it this
way.
I don't know how to make it such that when the user leaves the field in the
table, that the resulting value (870%) is divided by 100 so it shows 8.7%
(the goal).

If someone could explain how I can do the division I would be greatly
appreciative.

-Darryl.
"Anne Troy" wrote in message
news:1c097$42d4327b$97c5108d$4574@allthenewsgroups .com...
Hi, Darryl. The whole confusion about percentage formatting is that 8.7 is
not 8.7%. 8.7 percent formatted as a decimal is really 0.087, so that

needs
to be entered, or you need to divide it by 100 so it works the way you

want
it to. This also confuses Excel users.
*******************
~Anne Troy

www.OfficeArticles.com


"Darryl" wrote in message
...
It's not calculated. The user types in the value. The formatting was

to
get it a percentage.
So, the user types in 8.7 and the formatting changes it to 8.7%.


"Suzanne S. Barnhill" wrote in message
...
No macro needed. The fact that you have already applied a number

format
suggests that you're using a field. If it's an = field or (as sounds

more
likely) a calculated form field, all you have to do is add /100 to the
calculation.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
OK then.
How can I create a macro to divide the cell contents (that I am

exiting)
by
100 ?

thanks,
Darryl
"Suzanne S. Barnhill" wrote in message
...
In addition to adding a number format, you'll have to do some math

to
divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup
so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is

numeric
in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to

870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that
mathematically
converts it ?

Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org















  #10   Report Post  
Anne Troy
 
Posts: n/a
Default

Sorry, Darryl. Hope I didn't sound condescending--didn't mean to.
The easiest way to accomplish this would be to put the % outside the form
field and just format the cell as 0.00. Otherwise, methinks you'll need a
macro.
*******************
~Anne Troy

www.OfficeArticles.com


"Darryl" wrote in message
...
Thanks Anne.

I understand that 8.7 is not 8.7%. But as the users say, I need it this
way.
I don't know how to make it such that when the user leaves the field in

the
table, that the resulting value (870%) is divided by 100 so it shows 8.7%
(the goal).

If someone could explain how I can do the division I would be greatly
appreciative.

-Darryl.
"Anne Troy" wrote in message
news:1c097$42d4327b$97c5108d$4574@allthenewsgroups .com...
Hi, Darryl. The whole confusion about percentage formatting is that 8.7

is
not 8.7%. 8.7 percent formatted as a decimal is really 0.087, so that

needs
to be entered, or you need to divide it by 100 so it works the way you

want
it to. This also confuses Excel users.
*******************
~Anne Troy

www.OfficeArticles.com


"Darryl" wrote in message
...
It's not calculated. The user types in the value. The formatting was

to
get it a percentage.
So, the user types in 8.7 and the formatting changes it to 8.7%.


"Suzanne S. Barnhill" wrote in message
...
No macro needed. The fact that you have already applied a number

format
suggests that you're using a field. If it's an = field or (as sounds

more
likely) a calculated form field, all you have to do is add /100 to

the
calculation.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
OK then.
How can I create a macro to divide the cell contents (that I am

exiting)
by
100 ?

thanks,
Darryl
"Suzanne S. Barnhill" wrote in message
...
In addition to adding a number format, you'll have to do some

math
to
divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup
so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is
numeric
in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it

to
870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that
mathematically
converts it ?

Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



















  #11   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

Okay, I see what's happening, and yes, I suppose it will require a macro
unless there's some way to perform calculations on data a user enters.
Unfortunately, I have little experience with forms and no expertise with
macros, so someone else will have to help.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Darryl" wrote in message
...
It's not calculated. The user types in the value. The formatting was to
get it a percentage.
So, the user types in 8.7 and the formatting changes it to 8.7%.


"Suzanne S. Barnhill" wrote in message
...
No macro needed. The fact that you have already applied a number format
suggests that you're using a field. If it's an = field or (as sounds

more
likely) a calculated form field, all you have to do is add /100 to the
calculation.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
OK then.
How can I create a macro to divide the cell contents (that I am

exiting)
by
100 ?

thanks,
Darryl
"Suzanne S. Barnhill" wrote in message
...
In addition to adding a number format, you'll have to do some math

to
divide
by 100.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the

newsgroup
so
all may benefit.

"Darryl" wrote in message
...
Yes, of course I already knew that.

Rather, I want to enter 8.7 and have

the cell show 8.7%.

how do I accomplish that ?

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Greetings,
I have a table in my word document. One of the cells is

numeric
in
format. I have set the number format
to 0.00%. The problem is when I enter 8.7 it converts it to

870%.
I want it to be 8.7%.

How do I do this ? Do I have to create a macro that

mathematically
converts it ?

Enter
.087
instead.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org












  #12   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

Darryl was telling us:
Darryl nous racontait que :

Thanks Anne.

I understand that 8.7 is not 8.7%. But as the users say, I need it
this way.
I don't know how to make it such that when the user leaves the field
in the table, that the resulting value (870%) is divided by 100 so it
shows 8.7% (the goal).


Here is a little macro that does that:

'_______________________________________
Sub Divide100()

Dim myValue As Single

With ActiveDocument.Bookmarks("Value1").Range
myValue = CSng(Left(.Text, Len(.Text) - 1))
myValue = myValue / 10000
.FormFields(1).Result = CStr(myValue)

End With

End Sub

'_______________________________________

Note that I have to divide by 10 000 because when I do the calculation, the
number entered by the user a=has already been multiplied by a 100 because of
the number format...

The formfield name is Value1.
Either change the name in the macro, or change it in the form itself.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #13   Report Post  
Darryl
 
Posts: n/a
Default

Well,
I changed Value1 to my field name.
I have the field set as number, format 0.00%, macro on exit is
divide100.

When I run it, I get a type mismatch error. Looking at the macro,
I'm not sure why ? Form field is type number. Is the macro assuming
the field is text ?


"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Thanks Anne.

I understand that 8.7 is not 8.7%. But as the users say, I need it
this way.
I don't know how to make it such that when the user leaves the field
in the table, that the resulting value (870%) is divided by 100 so it
shows 8.7% (the goal).


Here is a little macro that does that:

'_______________________________________
Sub Divide100()

Dim myValue As Single

With ActiveDocument.Bookmarks("Value1").Range
myValue = CSng(Left(.Text, Len(.Text) - 1))
myValue = myValue / 10000
.FormFields(1).Result = CStr(myValue)

End With

End Sub

'_______________________________________

Note that I have to divide by 10 000 because when I do the calculation,

the
number entered by the user a=has already been multiplied by a 100 because

of
the number format...

The formfield name is Value1.
Either change the name in the macro, or change it in the form itself.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





  #14   Report Post  
Darryl
 
Posts: n/a
Default

Well, maybe isn't not a type mis-match. When I try to enter data in the
field and then leave it,
nothing happens (ie, 1.2 gets set to 120%). When I debug the macro it gives
an error saying that
the macro tries to access a protected area of the document. If I unprotect
the document, (ie, not a form), then nothing happens (as described above).


"Darryl" wrote in message
...
Well,
I changed Value1 to my field name.
I have the field set as number, format 0.00%, macro on exit is
divide100.

When I run it, I get a type mismatch error. Looking at the macro,
I'm not sure why ? Form field is type number. Is the macro assuming
the field is text ?


"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Thanks Anne.

I understand that 8.7 is not 8.7%. But as the users say, I need it
this way.
I don't know how to make it such that when the user leaves the field
in the table, that the resulting value (870%) is divided by 100 so it
shows 8.7% (the goal).


Here is a little macro that does that:

'_______________________________________
Sub Divide100()

Dim myValue As Single

With ActiveDocument.Bookmarks("Value1").Range
myValue = CSng(Left(.Text, Len(.Text) - 1))
myValue = myValue / 10000
.FormFields(1).Result = CStr(myValue)

End With

End Sub

'_______________________________________

Note that I have to divide by 10 000 because when I do the calculation,

the
number entered by the user a=has already been multiplied by a 100

because
of
the number format...

The formfield name is Value1.
Either change the name in the macro, or change it in the form itself.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org







  #15   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

Darryl was telling us:
Darryl nous racontait que :

Well,
I changed Value1 to my field name.
I have the field set as number, format 0.00%, macro on exit is
divide100.

When I run it, I get a type mismatch error. Looking at the macro,
I'm not sure why ? Form field is type number. Is the macro assuming
the field is text ?


I created a protected form with a text field set to number with the 0.00%
format, then I protected the form. My macro works. I just checked again, and
it worked. So we are doing things differently.
Describe how you created the field (and gave it a name) where the user
enters the value and the document itself (how is it protected, what does it
contain).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





  #16   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

Darryl was telling us:
Darryl nous racontait que :

Well, maybe isn't not a type mis-match. When I try to enter data in
the field and then leave it,
nothing happens (ie, 1.2 gets set to 120%). When I debug the macro
it gives an error saying that
the macro tries to access a protected area of the document. If I


OK, what Word Version?

unprotect the document, (ie, not a form), then nothing happens (as
described above).



That is normal because OnExit macros do not work when the document is not
protected for forms.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #17   Report Post  
Darryl
 
Posts: n/a
Default

I can send you the exact document as I might not answer properly. I am
using Word 2000
BTW, the document is a simple, one page form.


"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Well,
I changed Value1 to my field name.
I have the field set as number, format 0.00%, macro on exit is
divide100.

When I run it, I get a type mismatch error. Looking at the macro,
I'm not sure why ? Form field is type number. Is the macro assuming
the field is text ?


I created a protected form with a text field set to number with the 0.00%
format, then I protected the form. My macro works. I just checked again,

and
it worked. So we are doing things differently.
Describe how you created the field (and gave it a name) where the user
enters the value and the document itself (how is it protected, what does

it
contain).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





  #18   Report Post  
Darryl
 
Posts: n/a
Default



I created a brand new document with a table (inserted from the
forms toolbar) that had three columns. first, I put the insertion point
into column 1 row 1. Then selected text form field from the forms toolbar.
I then right clicked, chose properties and set the a field type to number.
Text format to 0.00%. Selected divide100 as the exit macro. Under the
field settings group box I set the bookmark to value1. Clicked OK.
Clicked form protect button on forms toolbar.

Then to test, put insertion point in column1 row 1 and typed 1.23 then
pressed the tab key. Immediately the type mis-match error 13 pops up.
press debug on the error dialog box and the debugger says the offending is:
myValue = CSng(Left(.Text, Len(.Text) - 1))

what am I doing wrong ?

thanks,
Darryl

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Well,
I changed Value1 to my field name.
I have the field set as number, format 0.00%, macro on exit is
divide100.

When I run it, I get a type mismatch error. Looking at the macro,
I'm not sure why ? Form field is type number. Is the macro assuming
the field is text ?


I created a protected form with a text field set to number with the 0.00%
format, then I protected the form. My macro works. I just checked again,

and
it worked. So we are doing things differently.
Describe how you created the field (and gave it a name) where the user
enters the value and the document itself (how is it protected, what does

it
contain).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





  #19   Report Post  
Doug Robbins
 
Posts: n/a
Default

Leave the formfield set as a text formfield and run a macro on exit from the
formfield that contains the following code:

With ActiveDocument.FormFields("Text1")
.result = Format(.result / 1000, "0.00%")
End With

replace "Text1" with the bookmark name assigned to the formfield.

--
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
"Darryl" wrote in message
...


I created a brand new document with a table (inserted from the
forms toolbar) that had three columns. first, I put the insertion point
into column 1 row 1. Then selected text form field from the forms
toolbar.
I then right clicked, chose properties and set the a field type to number.
Text format to 0.00%. Selected divide100 as the exit macro. Under the
field settings group box I set the bookmark to value1. Clicked OK.
Clicked form protect button on forms toolbar.

Then to test, put insertion point in column1 row 1 and typed 1.23 then
pressed the tab key. Immediately the type mis-match error 13 pops up.
press debug on the error dialog box and the debugger says the offending
is:
myValue = CSng(Left(.Text, Len(.Text) - 1))

what am I doing wrong ?

thanks,
Darryl

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Well,
I changed Value1 to my field name.
I have the field set as number, format 0.00%, macro on exit is
divide100.

When I run it, I get a type mismatch error. Looking at the macro,
I'm not sure why ? Form field is type number. Is the macro assuming
the field is text ?


I created a protected form with a text field set to number with the 0.00%
format, then I protected the form. My macro works. I just checked again,

and
it worked. So we are doing things differently.
Describe how you created the field (and gave it a name) where the user
enters the value and the document itself (how is it protected, what does

it
contain).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org







  #20   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

Darryl was telling us:
Darryl nous racontait que :

I can send you the exact document as I might not answer properly. I
am using Word 2000


Ha! Word 2000! I had done all my tests in Word 2003. Protected documents
behave differently in almost all versions of Word...

Try this instead:

'_______________________________________
Sub Divide100()

Dim myValue As Single

ActiveDocument.Unprotect

With ActiveDocument.FormFields("Value1")
myValue = CSng(Left(.Result, Len(.Result) - 1))
myValue = myValue / 10000
.Result = CStr(myValue)

End With

ActiveDocument.Protect wdAllowOnlyFormFields, True

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





  #21   Report Post  
Darryl
 
Posts: n/a
Default

Success!

But one question. In the divide100 subroutine, it references Value1. If I
have three
form fields (value1, value2, value3) and I want to call divide100 onexit of
each, how
would I modify the divide100 (put a conditional test ?)

-Darryl

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

I can send you the exact document as I might not answer properly. I
am using Word 2000


Ha! Word 2000! I had done all my tests in Word 2003. Protected documents
behave differently in almost all versions of Word...

Try this instead:

'_______________________________________
Sub Divide100()

Dim myValue As Single

ActiveDocument.Unprotect

With ActiveDocument.FormFields("Value1")
myValue = CSng(Left(.Result, Len(.Result) - 1))
myValue = myValue / 10000
.Result = CStr(myValue)

End With

ActiveDocument.Protect wdAllowOnlyFormFields, True

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





  #22   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

Darryl was telling us:
Darryl nous racontait que :

Success!

But one question. In the divide100 subroutine, it references Value1.
If I have three
form fields (value1, value2, value3) and I want to call divide100
onexit of each, how
would I modify the divide100 (put a conditional test ?)


Try something like this:

'_______________________________________
Sub Divide100()

Dim myValue As Single

ActiveDocument.Unprotect

With Selection.Range.Bookmarks(1).Range.FormFields(1)
If .Result = "" Then GoTo QuitSub 'in case field is empty
myValue = CSng(Left(.Result, Len(.Result) - 1))
myValue = myValue / 10000
.Result = CStr(myValue)
End With

QuitSub:
ActiveDocument.Protect wdAllowOnlyFormFields, True

End Sub
'_______________________________________

You may have to modify it a bit... I did not test it with Word 2000 this
time...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #23   Report Post  
Darryl
 
Posts: n/a
Default

This is what I came up with. It seems to work.

'_______________________________________
Sub Divide1002()
Dim myValue2 As Single

ActiveDocument.Unprotect

With
ActiveDocument.FormFields(Selection.Bookmarks(Sele ction.Bookmarks.Count).Nam
e)
myValue2 = CSng(Left(.Result, Len(.Result) - 1))
myValue2 = myValue2 / 10000
.Result = CStr(myValue2)

End With


ActiveDocument.Protect wdAllowOnlyFormFields, True

End Sub

'_______________________________________

"Jean-Guy Marcil" wrote in message
...
Darryl was telling us:
Darryl nous racontait que :

Success!

But one question. In the divide100 subroutine, it references Value1.
If I have three
form fields (value1, value2, value3) and I want to call divide100
onexit of each, how
would I modify the divide100 (put a conditional test ?)


Try something like this:

'_______________________________________
Sub Divide100()

Dim myValue As Single

ActiveDocument.Unprotect

With Selection.Range.Bookmarks(1).Range.FormFields(1)
If .Result = "" Then GoTo QuitSub 'in case field is empty
myValue = CSng(Left(.Result, Len(.Result) - 1))
myValue = myValue / 10000
.Result = CStr(myValue)
End With

QuitSub:
ActiveDocument.Protect wdAllowOnlyFormFields, True

End Sub
'_______________________________________

You may have to modify it a bit... I did not test it with Word 2000 this
time...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org





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
cell formatting [email protected] Microsoft Word Help 1 March 24th 05 12:05 PM
Form Fields lose bold formatting Ellen Microsoft Word Help 0 February 17th 05 10:11 PM
word table cell resize or word table cell size change or word table change cell size [email protected] Tables 0 January 13th 05 10:55 PM
numeric formatting within a cell diane Tables 1 December 15th 04 11:00 AM
Apply Style but keep direct formatting? Stefan Blom New Users 2 November 29th 04 12:30 AM


All times are GMT +1. The time now is 11:56 PM.

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"