Pop-up Calendar won't insert date into document

  • Thread starter Thread starter JFREE223
  • Start date Start date
J

JFREE223

I created a pop-up calendar and made it a toolbar option. Calendar displays,
I can seletct mm, dd, yyyy, but it doesn't insert the date. Any clue why it
won't insert? I've copied all the code from the fontstuff.com website.
 
Someone is more likely to be able to help you if you were to copy and paste
the code that YOU are using into a message that you post here.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
Thanks Doug,

The userform code is

Private Sub Calendar1_Click()
Selection.Text = Format(Calendar1.Value, "mmmm dd, yyyy")
Selection.MoveRight Unit:=wdCharacter, Count:=1
Unload Me
End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub


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

The formcalendar code is

Private Sub Calendar1_Click()

End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub


Private Sub UserForm_Click()

End Sub


Any help is appreciated.
 
See http://www.gmayor.com/popup_calendar.htm which you might find easier to
follow.

I can't see the deliberate mistake - The code that you have should insert
the date at the cursor position when you call the userform. If you want to
insert the date in an on-line form field the code needs to be modified.
What, if anything, is happening when you call the form?

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
It opens the calendar in my word doc when I select the calendar button on the
toolbar. Everything looks great, I select the date, it doesn't do anything
at that point. It's like flicking a light switch and nothing happens.
 
The following is the code copied from my own PC - which also shows the code
to insert the date into a form. This inserts the date at the cursor (or in
form field Text1). Apart from the local date formatting switch, it looks the
same as yours?

Private Sub Calendar1_Click()
'Dim oFld As FormFields
'Set oFld = ActiveDocument.FormFields
'oFld("Text1").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

Private Sub CmdClose_Click()
Unload Me
End Sub

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

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Thanks. I found this today. When I press F8 and run through the code on my
userform for initialize, I get a "runtime error '13' Type Mismatch."

It occurs on the third line of the code below...

Private Sub UserForm_Initialize()
If IsDate(Selection.Text) Then
Calendar1.Value = DateValue(Selection.Text)
Else
Calendar1.Value = Date
End If
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

Back
Top