Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add control at run time.

Y'all:

I am trying to add a control at run time on my user form. Using Excel
2002. If you go into the visual basic help and search on
"control.add" the very first item in the returned list is "AddControl
Event". The example that is given for the AddControl Event won't run
for me. I pasted it below. WHat is wrong with it?

russ




Dim Mycmd as Control
Private Sub CommandButton1_Click()

Set Mycmd = Controls.Add("MSForms.CommandButton.1") ',
CommandButton2, Visible)
Mycmd.Left = 18
Mycmd.Top = 150
Mycmd.Width = 175
Mycmd.Height = 20
Mycmd.Caption = "This is fun." & Mycmd.Name

End Sub

Private Sub UserForm_AddControl(ByVal Control As _
MSForms.Control)
Label1.Caption = "Control was Added."
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Add control at run time.

Hi Russell,

Try using "Forms.CommandButton.1" instead of "MSForms.CommandButton.1".

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Russell W. Patterson wrote:
Y'all:

I am trying to add a control at run time on my user form. Using Excel
2002. If you go into the visual basic help and search on
"control.add" the very first item in the returned list is "AddControl
Event". The example that is given for the AddControl Event won't run
for me. I pasted it below. WHat is wrong with it?

russ




Dim Mycmd as Control
Private Sub CommandButton1_Click()

Set Mycmd = Controls.Add("MSForms.CommandButton.1") ',
CommandButton2, Visible)
Mycmd.Left = 18
Mycmd.Top = 150
Mycmd.Width = 175
Mycmd.Height = 20
Mycmd.Caption = "This is fun." & Mycmd.Name

End Sub

Private Sub UserForm_AddControl(ByVal Control As _
MSForms.Control)
Label1.Caption = "Control was Added."
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Add control at run time.


"Russell W. Patterson" wrote in message
om...
Y'all:

I am trying to add a control at run time on my user form. Using Excel
2002. If you go into the visual basic help and search on
"control.add" the very first item in the returned list is "AddControl
Event". The example that is given for the AddControl Event won't run
for me. I pasted it below. WHat is wrong with it?

russ




Dim Mycmd as Control
Private Sub CommandButton1_Click()


Change this

Set Mycmd = Controls.Add("MSForms.CommandButton.1") ',
CommandButton2, Visible)


to

Set Mycmd = Controls.Add("Forms.CommandButton.1") , _
CommandButton2, Visible)

and it'll work

Keith


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add control at run time.



Guys: Thanks. Changeing to "Forms..." made it work.

Now, how can I adjust to make it work with the ProgressBar control?

thanks,
russ


*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Add control at run time.

Hi Russell,

MSComctlLib.ProgCtrl.2

You can get these pretty easily - go to Excel, bring up the Control toolbox,
then select additional controls. Find the Microsoft Progressbar Control and
insert it on the worksheet. When you insert it, you'll see the ProgID in
the formula bar:

=EMBED("MSComctlLib.ProgCtrl.2","")

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Russell Patterson wrote:
Guys: Thanks. Changeing to "Forms..." made it work.

Now, how can I adjust to make it work with the ProgressBar control?

thanks,
russ


*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Reply
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
Looking for a flexi-time control spreadsheet rodneythomasjones Excel Discussion (Misc queries) 1 December 2nd 07 11:06 PM
date and time picker control Ashku Excel Discussion (Misc queries) 0 July 22nd 06 11:18 AM
Problem With Date and Time Picker Control 6.0 Sunnous Excel Discussion (Misc queries) 1 May 27th 05 04:23 PM
microsoft date and time picker control Don Excel Discussion (Misc queries) 2 May 20th 05 02:27 PM
Date and Time Picker Control Andy T Excel Discussion (Misc queries) 0 January 6th 05 04:09 PM


All times are GMT +1. The time now is 06:53 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"