cell formatting

D

Darryl

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
 
J

Jean-Guy Marcil

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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Darryl

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

'_______________________________________
Sub Divide1002()
Dim myValue2 As Single

ActiveDocument.Unprotect

With
ActiveDocument.FormFields(Selection.Bookmarks(Selection.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

'_______________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top