LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default adding controls to userform at runtime


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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform runtime controls & Macs Jim Cowan Excel Programming 0 June 15th 05 07:21 PM
Adding controls to userform ExcelMonkey[_190_] Excel Programming 3 February 25th 05 11:30 AM
Removing Controls at RunTime? Neily[_3_] Excel Programming 1 November 25th 04 02:17 PM
How to create controls at runtime Andy Chan Excel Programming 3 August 30th 04 10:07 AM
creating controls at runtime defj Excel Programming 2 December 2nd 03 07:14 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"