Results 1 to 4 of 4
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What page of Userform Control? (Word 2000+)

    I couldn't find an easy way (via .Properties) of determining which page (tab) in a multi-page control housed a particular control.
    The attached module appears to work, but it is clunky.
    I iterate through all controls in a user form to locate the multipage controls;
    I examine each page within each multipage control to match the name of a specific control.
    If the names match, then I have found the page which houses that control.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: What page of Userform Control? (Word 2000+)

    The Parent of a control on a MultiPage control is the Page on which it resides.
    The Parent of the Parent of such a control is the MultiPage control.
    The Parent of the Parent of the Parent is the UserForm.

    ? UserForm1.TextBox1.Parent.Name
    Page2

    ? UserForm1.TextBox1.Parent.Parent.Name
    MultiPage1

    ? UserForm1.TextBox1.Parent.Parent.Parent.Name
    UserForm1

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What page of Userform Control? (Word 2000+)

    Thanks, Hans.
    The Parent is occasionaly invisible when I pore/paw over the entrails of my local variables.
    I'm documenting a user form, so I suspect I'll test the TypeName of the control's parent,
    and if it is a page, then obtain the name of the page.

    <pre>?typename(ctl)
    TextBox
    ?typename(ctl.Parent)
    Page
    ?ctl.Parent.name
    Sources</pre>


  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What page of Userform Control? (Word 2000+)

    (Updated function)
    <pre>Function strListControls(frmMe As UserForm) As String
    Dim strResult As String
    strResult = "Name" & vbTab & "Type" & vbTab & "Caption" & vbTab & "Page" & vbCrLf
    Dim lng As Long
    On Error Resume Next
    For lng = 1 To frmMe.Controls.Count
    Dim ctl As Control
    Set ctl = frmMe.Controls(lng - 1)
    strResult = strResult & ctl.Name & vbTab
    strResult = strResult & TypeName(ctl) & vbTab
    strResult = strResult & ctl.Caption & vbTab
    If TypeName(ctl.Parent) = "Page" Then
    strResult = strResult & ctl.Parent.Name & vbTab
    Else
    End If
    strResult = strResult & vbCrLf
    Next lng
    strListControls = strResult
    'Sub TESTstrListControls()
    ' Selection.TypeText (strListControls(frmGUI))
    ' Selection.WholeStory
    ' Selection.ConvertToTable Separator:=wdSeparateByTabs
    'End Sub
    End Function</pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •