Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would appreciate further comment re your solution to copy pasting controls
and your code: Private Sub CommandButton1_Click() Dim newPage As Page Dim nPages As Long With Me.MultiPage1 nPages = .Count Set newPage = .Pages.Add("Page" & (nPages + 1), _ "Address " & (nPages + 1), nPages) .Pages(1).Controls.Copy End With newPage.Paste End Sub ''I assume you have addressed how to add new event code to the pasted controls. '' I have 2 questions 1. Using the above, I find each control is pasted to the left of the original position. They are alll drawn relative to each other just shifted to the left. How would you correct this? 2. How do you sub-class the event code for each control collection? I would be very grateful if you could expand a little on your previous comments Geoff Code as follows: For a cmdbutton on a page I have in the form code: Private Sub cmdDeleteChanges_Click() '''clear controls ClearControls (MultiSetasides.Value) '''set focus on first empty control FirstControl (MultiSetasides.Value) End Sub Then in a standard module I have: Sub FirstControl(k As Byte) Dim i As Byte '''ignore main page If Not frmMulti.MultiSetasides.Value = 0 Then Set ctrl = frmMulti.MultiSetasides.Pages(k).Controls For i = 0 To 9 If (TypeOf ctrl.Item(i) Is msForms.TextBox) Then If Trim(ctrl.Item(i).Text) = "" Then Exit For ElseIf (TypeOf ctrl.Item(i) Is msForms.OptionButton) Then If ctrl.Item(i).Value = False And ctrl.Item(i + 1).Value = False Then Exit For End If Next i ctrl.Item(i).SetFocus End If End Sub Sub ClearControls(k As Byte) Dim i As Byte '''ignore main page If Not frmMulti.MultiSetasides.Value = 0 Then Set ctrl = frmMulti.MultiSetasides.Pages(k).Controls For i = 1 To 9 If (TypeOf ctrl.Item(i) Is msForms.TextBox) Then ctrl.Item(i).Text = "" ElseIf (TypeOf ctrl.Item(i) Is msForms.OptionButton) Then ctrl.Item(i).Value = False End If Next i End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Add controls to Frames at Runtime | Excel Programming | |||
Does anyone have a copy of the Peter Noneley: Function list? | New Users to Excel | |||
Removing Controls at RunTime? | Excel Programming | |||
How to create controls at runtime | Excel Programming | |||
creating controls at runtime | Excel Programming |