Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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.CommandButto n.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! -- Ouka ------------------------------------------------------------------------ Ouka's Profile: http://www.excelforum.com/member.php...o&userid=23988 View this thread: http://www.excelforum.com/showthread...hreadid=396719 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello to add a calendar at run time in a userform , you may try Dim Usf As Object Dim Obj As MSACal.Calendar Set Usf = ThisWorkbook.VBProject.VBComponents("Userform1") Set Obj = Usf.Designer.Controls.Add("MSCAL.Calendar.7") With Obj ..Left = 20: .Top = 20: .Width = 200: .Height = 150 End With VBA.UserForms.Add (Usf.Name) UserForms(0).Show Regards michel -- michelxld ------------------------------------------------------------------------ michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367 View this thread: http://www.excelforum.com/showthread...hreadid=396719 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thank you for the reply. THis code works when I'm using it as a stand alone, but for some reason when I incorperate it into the userform I've already built it does not. The code fires, everything that is supposed to happen, happens except that no userform is displayed. I remove the calendar code and the form is displayed again. What excatly does the "7" do in: Set Obj = Usf.Designer.Controls.Add("MSCAL.Calendar.7") ? -- Ouka ------------------------------------------------------------------------ Ouka's Profile: http://www.excelforum.com/member.php...o&userid=23988 View this thread: http://www.excelforum.com/showthread...hreadid=396719 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Nevermind, they are index numbers. Now I see what was going wrong. everyone /bonk the newbie! -- Ouka ------------------------------------------------------------------------ Ouka's Profile: http://www.excelforum.com/member.php...o&userid=23988 View this thread: http://www.excelforum.com/showthread...hreadid=396719 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Userform runtime controls & Macs | Excel Programming | |||
Adding controls to userform | Excel Programming | |||
Removing Controls at RunTime? | Excel Programming | |||
How to create controls at runtime | Excel Programming | |||
creating controls at runtime | Excel Programming |