Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    May 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel UserForm ListBox (Windows 98 SE)

    I'm in Windows 98SE using VBA to develop a UserForm for input to an Excel 2k worksheet. On the form I have several listboxes. The first line of each listbox is "choose ..."; the user selects from each list and the selected item shows up as white-on-black (reverse type). So far, so good.

    But when I print the UserForm, the selected entries also print in reverse type. I want them to print black-on-white, the way the rest of the form does.

    I've tried setting the BackColor and ForeColor properties of the list boxes to vbWhite and vbBlack, respectively, in the print routine, but that also sets the contents back to "choose ...".

    I've also tried setting the ListStyle property to Option. The option buttons show up and print with the list item, but they still print in reverse type.

    Is there a way to fix this so that the selected items print on the UserForm, but in standard black-on-white?

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Excel UserForm ListBox (Windows 98 SE)

    Just set SelStart to 0. See sample below. HTH --Sam
    <pre>Option Explicit

    Private Sub CommandButton1_Click()
    With ComboBox1
    .SelStart = 0
    Me.PrintForm
    .SelLength = Len(.Text)
    .SetFocus
    End With
    End Sub

    Private Sub UserForm_Initialize()
    With ComboBox1
    .AddItem "Choose"
    .AddItem "Sam"
    .AddItem "Brett"
    .ListIndex = 0
    End With
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

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