ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Frame Index (https://www.excelbanter.com/excel-programming/292280-re-frame-index.html)

Tom Ogilvy

Frame Index
 
You can do something like this:

Private Sub CommandButton1_Click()
Dim frm(0 To 2) As MSForms.Frame
Dim tmp As MSForms.Frame
Dim pg As MSForms.Page
For Each pg In UserForm1.MultiPage1.Pages
i = 0
For Each ctrl In pg.Controls
If TypeOf ctrl Is MSForms.Frame Then
Set frm(i) = ctrl
i = i + 1
End If
Next
If i 1 Then
If frm(0).Left frm(1).Left Then
Set tmp = frm(1)
Set frm(1) = frm(0)
Set frm(0) = tmp
End If
End If
For i = 0 To 1
If Not frm(i) Is Nothing Then
Debug.Print pg.Caption & " " & frm(i).Name
End If
Next
Next

End Sub

--
Regards,
Tom Ogilvy

"aspadda" wrote in message
...
Here is a situation : I have a form with multipage control (Multipage has

6 pages). On each page i have 2 frames. I want to access the frames (through
code) in a sequence (for eg : page1.frame1 and then page1.frame2 and then
page2.frame2.page1 and so on.........). I am using the below code and what
happens is that it picks the sequence as frames were created..(for eg you
created a frame on page 2 and then you went back and created another frame
on frame 1...it takes the the frame created on page 2 first and then the
frame created on page 1) but i want the other way around. I went and looked
into properties to set the index but that does'nt work.

Help will be appreciated...

Code


Private Sub CommandButton1_Click()
Dim ctrl As Control
Dim msg As String
For Each ctrl In UserForm1.Controls
If LCase(Mid(ctrl.Name, 1, 3)) = "fra" Then
msg = msg & vbNewLine & ctrl.Name
End If
Next ctrl
MsgBox msg
End Sub





All times are GMT +1. The time now is 12:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com