O
Ouka
Hi all,
Need some syntax help here.
How do you add a calendar control to a runtime-built userform?
I can do it with some code I snipped from somewhere for standard MS
controls ala:
Code:
--------------------
Function CreateForm
Dim TempForm As Object
Dim OKButton as MSForms.CommandButton
Dim Code as String
Set OKButton = TempForm.Designer.Controls.Add("forms.CommandButton.1")' ***
With OKButton
.caption = "OK"
.Height = 18
.Width = 44
.Left = 10
.Top = 10
End With
'insert additional code to set size of form
'following code defines actions on click:
Code = ""
Code = Code & Sub OKButton_click()" & vbCrLf
Code = Code & " Unload Me" & vbCrLf
Code = Code & "End Sub" & vbCrLf
'Show the form
VBA.UserForms.Add(TempForm.Name).Show
'Delete the form
ThisWorkbook.VBProject.VBComponents.Remove VBComponent:=TempForm
End Function
--------------------
I have successfully Dim'ed the calendar ala:
Dim NewCalendar as MSACal.Calendar
but I can't seem to actually add the control. I believe my problem is
at the *** above and getting the right syntax for adding the calendar
with a similar block.
When the code runs, no form is created but no error is thrown. When I
remove the calendar-specific code, the form is created properly.
Any help would be most appreciated!
Need some syntax help here.
How do you add a calendar control to a runtime-built userform?
I can do it with some code I snipped from somewhere for standard MS
controls ala:
Code:
--------------------
Function CreateForm
Dim TempForm As Object
Dim OKButton as MSForms.CommandButton
Dim Code as String
Set OKButton = TempForm.Designer.Controls.Add("forms.CommandButton.1")' ***
With OKButton
.caption = "OK"
.Height = 18
.Width = 44
.Left = 10
.Top = 10
End With
'insert additional code to set size of form
'following code defines actions on click:
Code = ""
Code = Code & Sub OKButton_click()" & vbCrLf
Code = Code & " Unload Me" & vbCrLf
Code = Code & "End Sub" & vbCrLf
'Show the form
VBA.UserForms.Add(TempForm.Name).Show
'Delete the form
ThisWorkbook.VBProject.VBComponents.Remove VBComponent:=TempForm
End Function
--------------------
I have successfully Dim'ed the calendar ala:
Dim NewCalendar as MSACal.Calendar
but I can't seem to actually add the control. I believe my problem is
at the *** above and getting the right syntax for adding the calendar
with a similar block.
When the code runs, no form is created but no error is thrown. When I
remove the calendar-specific code, the form is created properly.
Any help would be most appreciated!