Thread: cell formatting
View Single Post
  #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