How do I enter a calendar in a field for a form created in Word.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a form to send home with my students everyday. I have created
fields with drop down lists for all the different categories. I wanted a
field that has a calendar help, that will pop up a calendar for the user to
choose the date on the calendar
 
It is a bit complicated to do this well - however most of the work has been
done for you in the first part of
http://www.fontstuff.com/word/wordtut03a.htm, however it needs a small
change to one of the macros to get it to relate to your form
Let's assume that the date you wish to pick is going to go in form field
Text2

Run the macro OpenCalendar() on entry to the field Text2

Change the macro
Private Sub Calendar1_Click to read

Private Sub Calendar1_Click()
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
oFld("Text2").Result = Format(Calendar1.Value, "dd mmmm yyyy")
' Selection.Text = Format(Calendar1.Value, "dd mmmm yyyy")
' Selection.MoveRight Unit:=wdCharacter, Count:=1
Unload Me
End Sub

(I have left in the old lines for reference)

The calendar pops up as you tab into the field Text2 and shows any date
already present in the field or the current date. You can modify this
behaviour eg if you wish to set the start date as 30 days hence, you can
modify the following module:

Private Sub UserForm_Initialize()
'If IsDate(Selection.Text) Then
' Calendar1.Value = DateValue(Selection.Text)
'Else
Calendar1.Value = Date + 30
'End If
End Sub

The Word 2003 version of the MSCAL.OCX file referred to in the web page will
also work with Word 2007.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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

Back
Top