D
Dylan
I have several userforms and each contain a calendar popup. They all worked
perfectly until today. Now they have all stoppped working.
The problem appears at line 16 when the word "Format" appears highlighted in
blue and an error message appears stating "Compile error - wrong number of
arguments or invalid property assignment"
my calendar control is called ctrCal and my userform is called frmCalendar
Private Sub ctrlCal_Click() 'Control Name
Dim rng As Range
Dim bProtect as Boolean
Set rng = Selection.Range
On Error Resume Next
'Unprotect
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
'If rng.Columns = 2 Then
With rng.Cells(1)
.Range.FormFields(1).Result = Format(ctrlCal.Value, "dd MMM yyyy")
End With
Unload Me
ActiveDocument.Tables(4).Range.FormFields("txtHidden").Select
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub
'Dylan
perfectly until today. Now they have all stoppped working.
The problem appears at line 16 when the word "Format" appears highlighted in
blue and an error message appears stating "Compile error - wrong number of
arguments or invalid property assignment"
my calendar control is called ctrCal and my userform is called frmCalendar
Private Sub ctrlCal_Click() 'Control Name
Dim rng As Range
Dim bProtect as Boolean
Set rng = Selection.Range
On Error Resume Next
'Unprotect
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
'If rng.Columns = 2 Then
With rng.Cells(1)
.Range.FormFields(1).Result = Format(ctrlCal.Value, "dd MMM yyyy")
End With
Unload Me
ActiveDocument.Tables(4).Range.FormFields("txtHidden").Select
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub
'Dylan