E
erik
hello everybody,
On the internet I found a program to enter a date in my document by clicking
on a calendar userform. It works fantastically, but I would like to use it a
little different and don't exactly know how.
In my document I have textboxes from the forms toolbar (grey fields you have
to fill out). I want to open the calendar when I click on the textbox (i use
a macro when assessing the box) and when I select the date it has to be
inserted within the grey field, keeping the grey field and bookmark.
A few issues: When I have locked the page my program says it cannot write to
a locked position. When I have the page 'open' the date overwrites the grey
field and the date cannot be altered by using the macro as I meant it.
Who has a suggestion for me? The code I use is:
Private Sub Calendar1_Click()
' Transfer date selected on calendar to the insertion
' insertion and close UserForm.
Selection.Text = Format(Calendar1.Value, "dd mmmm yyyy")
Unload Me
End Sub
Private Sub cmdClose_Click()
' Close the form without entering a date if the user
' presses the [ESCAPE] key
Unload Me
End Sub
Private Sub UserForm_Initialize()
' If selection is a date show the same date, otherwise show
' today's date.
If IsDate(Selection.Text) Then
Calendar1.Value = DateValue(Selection.Text)
Else
Calendar1.Value = Date
End If
End Sub
Hope you can help me!!!
thnx,
Erik
On the internet I found a program to enter a date in my document by clicking
on a calendar userform. It works fantastically, but I would like to use it a
little different and don't exactly know how.
In my document I have textboxes from the forms toolbar (grey fields you have
to fill out). I want to open the calendar when I click on the textbox (i use
a macro when assessing the box) and when I select the date it has to be
inserted within the grey field, keeping the grey field and bookmark.
A few issues: When I have locked the page my program says it cannot write to
a locked position. When I have the page 'open' the date overwrites the grey
field and the date cannot be altered by using the macro as I meant it.
Who has a suggestion for me? The code I use is:
Private Sub Calendar1_Click()
' Transfer date selected on calendar to the insertion
' insertion and close UserForm.
Selection.Text = Format(Calendar1.Value, "dd mmmm yyyy")
Unload Me
End Sub
Private Sub cmdClose_Click()
' Close the form without entering a date if the user
' presses the [ESCAPE] key
Unload Me
End Sub
Private Sub UserForm_Initialize()
' If selection is a date show the same date, otherwise show
' today's date.
If IsDate(Selection.Text) Then
Calendar1.Value = DateValue(Selection.Text)
Else
Calendar1.Value = Date
End If
End Sub
Hope you can help me!!!
thnx,
Erik