Need Advice on Approach to Project-Input Box?UserForm?

C

Cathy D.

I'm using Word 2002. I've created a contract template with form fields to
be filled in by the users. However, in one area of the contract I need to
prompt the user with something like this: "Are you attaching a Notice to
Proceed from the client?" If the user states yes, then in that area of the
contract, I need to put in a typed phrase like "pursuant to a Notice to
Proceed from the client attached hereto." If the user states no, I need to
prompt them for the contract number and name, and then have that inserted
into the contract instead.

I'm really new at vba and not sure whether I need to create a user form to
do this, or if it can be done through input boxes, or if there is another
approach I should take. Any advice and help with the code would be greatly
appreciated.

Cathy
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Cathy D. > écrivait :
In this message, < Cathy D. > wrote:

|| I'm using Word 2002. I've created a contract template with form fields
to
|| be filled in by the users. However, in one area of the contract I need
to
|| prompt the user with something like this: "Are you attaching a Notice to
|| Proceed from the client?" If the user states yes, then in that area of
the
|| contract, I need to put in a typed phrase like "pursuant to a Notice to
|| Proceed from the client attached hereto." If the user states no, I need
to
|| prompt them for the contract number and name, and then have that inserted
|| into the contract instead.
||
|| I'm really new at vba and not sure whether I need to create a user form
to
|| do this, or if it can be done through input boxes, or if there is another
|| approach I should take. Any advice and help with the code would be
greatly
|| appreciated.
||

Create a text formfield where you want to place the result. Deactivate it
(so the user cannot tab into it) and, for the example below, name it
"NoticeSpot" (without the quotes).
Finally, in the formfield preceding this "NoticeSpot" field, use the
following macro as an OnExit macro.

'_______________________________________
Sub AskUser()

Dim MyQuestion As Long
Dim ContractName As String

Const InsertText As String = "pursuant to a Notice to " _
& "Proceed from the client attached hereto."

MyQuestion = MsgBox("Are you attaching a Notice " _
& "to Proceed from the client?", _
vbInformation + vbYesNo, "Notice?")

With ActiveDocument.FormFields("NoticeSpot")
'6 = Yes
'7 = No
If MyQuestion = 6 Then
.Result = InsertText
Else
ContractName = InputBox("Type the contract number and name, " _
& "separated by a comma.", "Contract Details", "1111, Name")
.Result = ContractName
End If
End With

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
C

Cathy D.

Jean-Guy,

Thank you so much for your help. The code you gave me below works great,
plus I found it easy to understand and learn from. Thanks again!!

Cathy
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Cathy D. > écrivait :
In this message, < Cathy D. > wrote:

|| Jean-Guy,
||
|| Thank you so much for your help. The code you gave me below works great,
|| plus I found it easy to understand and learn from. Thanks again!!
||

Glad I could help.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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