Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    changeing font color with vba (2003)

    Hi,

    I am trying to make a form so the user can configure text and background colors.

    The backgrounf color is fine but I am having trouble getting the font color right, I only want the control labels changed, not command buttons etc. Heres what I got so far

    For i = 1 To Me.Controls.Count
    Me.Controls(i).ForeColor = strFontCol
    Next i

    Is there a way I can tag a control so it only changes font color if its taged or can I specify type of controls i.e. text boxes

    Thanks
    Regards
    Gerbil (AKA Kevin)

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

    Re: changeing font color with vba (2003)

    You can use code like this:

    Dim ctl As Control
    For Each ctl In Me.Controls
    Select Case ctl.ControlType
    Case acLabel, acTextBox, acComboBox, acListBox, _
    acCommandButton, acToggleButton
    ctl.ForeColor = strFontCol
    End Select
    Next ctl

    Note: ForeColor is of type Long, not of type String, so strFontCol is confusing.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: changeing font color with vba (2003)

    Thanks Hans works great!
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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