Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Wishlist? Print list of controls (WinNT4/Word97)

    I think this is wishful thinking, but just in case it is possible - does anyone know of a way of printing/producing a list of all the items on a userform? I don't need it formatted particularly, just a list so I can see at a glance what I called a particular control or whatever.

    I usually print a copy of the form and note the ones I need on it by hand, but my current project is very complicated and I'm getting fed up with redoing it!

    Many thanks
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Beryl M


  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wishlist? Print list of controls (WinNT4/Word97)

    I used this code for a project in Excel:

    Sub test()
    Dim ccontrol As MSForms.Control
    Dim lcount As Long
    lcount = 215
    On Error Resume Next
    For Each ccontrol In Userform1.Controls
    lcount = lcount + 2
    With Worksheets("Sheet1")
    .Cells(lcount, 2).Value = ccontrol.Name
    .Cells(lcount, 3).Value = "Caption"
    .Cells(lcount, 4).Value = ccontrol.Caption
    .Cells(lcount + 1, 2).Value = ccontrol.Name
    .Cells(lcount + 1, 3).Value = "Controltiptext"
    .Cells(lcount + 1, 4).Value = ccontrol.ControlTipText

    End With
    Next
    End Sub
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Wishlist? Print list of controls (WinNT4/Word97)

    Looks good ... only I'm in Word ...!
    Beryl M


  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wishlist? Print list of controls (WinNT4/Word97)

    I know too little of the Word object model to quickly change this code to Word, maybe someone else will jump in...
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Wishlist? Print list of controls (WinNT4/Word97)

    's okay - I did it myself! <img src=/S/grin.gif border=0 alt=grin width=15 height=15> As follows:
    <pre>Sub test()
    Dim ccontrol As MSForms.Control
    Dim lcount As Long
    lcount = 1
    On Error Resume Next
    For Each ccontrol In frmM1.Controls
    lcount = lcount + 1
    ActiveDocument.Content = ActiveDocument.Content + ccontrol.Name + vbTab + ccontrol.Caption _
    + vbTab + ccontrol.ControlTipText + vbLf
    Next
    End Sub</pre>

    It needs a bit of tweaking (I've not put headings or anything and it comes up double spaced) but it provides the info I needed.

    Many thanks for pointing me in the right direction!
    Beryl M


  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Wishlist? Print list of controls (WinNT4/Word97)

    You could make this code a little more efficient by replacing the line
    <code>ActiveDocument.Content = ActiveDocument.Content + ccontrol.Name + vbTab + ccontrol.Caption _</code>
    with
    <code>ActiveDocument.Content.InsertAfter ccontrol.Name + vbTab + ccontrol.Caption _</code>

    This avoids replacing the text that is already there all the time.

    StuartR

Posting Permissions

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