Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Adding checkbox within a frame

I have couple of 100 templates and inorder to make a global change (Adding a
frame and a checkbox on form) to all of them, i was trying the below
mentioned code.

What i was doing was opening each template at time..making the design time
change and saving it before closing.

Problem : It adds the frame and then the checkbox on the form. But i want to
add the checkbox in the frame. Any ideas!...


Sub Add_Control()
' Declare variables.
Dim mynewform As Object
Dim myframe As Object
Dim mycheckbox As Object
' to manipulate the UserForm.
Set mynewform =
Workbooks(workbook_Name).VBProject.VBComponents.It em(form_Name)

'Adding a frame
Set myframe = mynewform.Designer.Controls.Add("Forms.Frame.1")
With myframe
.Name = "frame1"
.Top = 180
.Left = 390
.Height = 60
.Width = 202
.BorderStyle = 1
End With

'Add a checkbox.
Set mycheckbox = mynewform.Designer.Controls.Add("Forms.checkBox.1" )
With mycheckbox
.Name = "chk_1"
.Top = 6
.Left = 6
.Height = 14.25
.Width = 198
End With

End Sub

--
Ajit
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Adding checkbox within a frame

Ajit,

Try changing
Set mycheckbox = mynewform.Designer.Controls.Add("Forms.checkBox.1" )
to
Set mycheckbox = myframe.Designer.Controls.Add("Forms.checkBox.1")

so that you are adding the control to the frame, not the form.

HTH,
Bernie
MS Excel MVP

"Ajit" wrote in message
...
I have couple of 100 templates and inorder to make a global change (Adding

a
frame and a checkbox on form) to all of them, i was trying the below
mentioned code.

What i was doing was opening each template at time..making the design time
change and saving it before closing.

Problem : It adds the frame and then the checkbox on the form. But i want

to
add the checkbox in the frame. Any ideas!...


Sub Add_Control()
' Declare variables.
Dim mynewform As Object
Dim myframe As Object
Dim mycheckbox As Object
' to manipulate the UserForm.
Set mynewform =
Workbooks(workbook_Name).VBProject.VBComponents.It em(form_Name)

'Adding a frame
Set myframe = mynewform.Designer.Controls.Add("Forms.Frame.1")
With myframe
.Name = "frame1"
.Top = 180
.Left = 390
.Height = 60
.Width = 202
.BorderStyle = 1
End With

'Add a checkbox.
Set mycheckbox = mynewform.Designer.Controls.Add("Forms.checkBox.1" )
With mycheckbox
.Name = "chk_1"
.Top = 6
.Left = 6
.Height = 14.25
.Width = 198
End With

End Sub

--
Ajit



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
Dynamically Adding Textbox To Frame sarndt Excel Worksheet Functions 0 March 15th 10 06:19 PM
adding a checkbox Pat Excel Discussion (Misc queries) 2 January 26th 07 03:05 PM
Adding a Checkbox in Cells Chaplain Doug Excel Discussion (Misc queries) 3 May 15th 06 04:00 PM
How to attach legend frame to chart frame? holg3r Charts and Charting in Excel 2 July 7th 05 11:41 PM
Problem in adding item to a checkbox Shilps Excel Programming 3 April 17th 04 11:56 AM


All times are GMT +1. The time now is 05:44 PM.

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

About Us

"It's about Microsoft Excel"