Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Jason K. Jason K. is offline
external usenet poster
 
Posts: 5
Default calendar Object

I'm trying to use the calendar object in an online form I created. The code I
have was written by Martin Green
(http://www.fontstuff.com/word/wordtut03a.htm). It works great on the
computer I created the fields with (Word 03) but when I send the form to
another computer (Word 02) I get an error message that says "This method or
property is not available because the object refers to a protected area of
the document." If I unlock the form in Word 02 I can run the macro just fine.

The code looks like this (Form Code)
Private Sub Calendar1_Click()
' Transfer date selected on calendar to the insertion
' insertion and close UserForm.
Selection.Text = Format(Calendar1.Value, "m/d/yy")
Selection.MoveRight Unit:=wdCharacter, Count:=1
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


The code looks like this (This Document Code)
Sub OpenCalendar()
' Display the frmCalendar UserForm
frmCalendar.Show
End Sub

Private Sub Document_Close()
On Error Resume Next
CustomizationContext = NormalTemplate
' Cancel the keyboard shortcut "Ctrl+Shift+C"
KeyBindings.Key(KeyCode:=BuildKeyCode(wdKeyControl , _
wdKeyShift, wdKeyC)).Clear
' Remove the "Insert Date" command from the right-click menu
Application.CommandBars("Text").Controls("Insert Date").Delete
End Sub

Private Sub Document_Open()
Dim NewControl As CommandBarControl
' Assign the keyboard shortcut "Ctrl+Shift+C"
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, _
wdKeyShift, wdKeyC), KeyCategory:=wdKeyCategoryMacro, _
Command:="ThisDocument.OpenCalendar"
' Add the "Insert Date" command to the right-click menu
Set NewControl = Application.CommandBars("Text").Controls.Add
With NewControl
..Caption = "Insert Date"
..OnAction = "ThisDocument.OpenCalendar"
..BeginGroup = True
End With
End Sub

Martin's website says it should work on most versions of Word.
Maybe I need the form to unlock, launch the calendar object, and then
re-lock? Or, maybe there is another way? Something I'm missing?

If you have the time to take a look at this, I would be very appreciative.

Jason K.
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
calendar control tikchye_oldLearner57 Microsoft Word Help 2 July 30th 06 02:15 AM
I used a 2006 Word Calendar Template last year, it was calendar wi PADutchman New Users 2 July 15th 06 02:52 AM
Calendar object Slow Learner Microsoft Word Help 0 September 10th 05 07:21 PM
Adding Border to an object moves the caption!?? bandy2000 Microsoft Word Help 1 March 27th 05 04:21 PM
MS Word Picture Object tj Microsoft Word Help 0 January 26th 05 03:09 AM


All times are GMT +1. The time now is 09:11 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"