Thread: [Solved] word 2003 date picker
View Single Post
 
Old 09-28-2010, 04:17 PM
Kimberly Kimberly is offline Windows 7 Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Posts: 517
Kimberly is on a distinguished road
Default

By default the first calendar you insert is named Calendar1
By default the second calendar you insert is named Calendar2
(right-click on a calendar and choose Properties to see this)

So if Calendar1 is for EffectiveDate: , the code should look like:

Code:
Private Sub Calendar1_Click()
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "EffectiveDate: "
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.MoveRight Unit:=wdCharacter, Count:=11, Extend:=wdExtend
    Selection.Text = Format(Calendar1.Value, "mmm dd yyyy")
End Sub
If the ExpirationDate: calendar is named Calendar2, then the code will be like the above, with three exceptions... the calendar name (twice) and the text to find. I suspect you did not edit the final line to be the value for Calendar2.
Reply With Quote