Microsoft Excel Webinar

Results 1 to 7 of 7

Thread: change font color for disable textbox

  1. #1

    change font color for disable textbox

    Hello

    I like to know if this is possible: change font color for disable textbox. For the moment it is an gray font text + shadow (or at least to take the shadow out):

    the code:

    VB:
    Private Sub Check() 
        Dim i As Integer 
         
        For i = 1 To 10 
            If Me.Controls("CheckBox" & i) = True Then 
                Me.Controls("TextBox" & i).Enabled = True 
                Me.Controls("TextBox" & i + 10).Enabled = True 
                Me.Controls("TextBox" & i + 20).Enabled = True 
                Me.Controls("TextBox" & i + 30).Enabled = True 
                Me.Controls("TextBox" & i).BackColor = &H80000005 
                Me.Controls("TextBox" & i).ForeColor = RGB(255, 0, 0) 
                Me.Controls("TextBox" & i + 10).BackColor = &H80000005 
                Me.Controls("TextBox" & i + 10).ForeColor = RGB(255, 0, 0) 
                Me.Controls("TextBox" & i + 20).BackColor = &H80000005 
                Me.Controls("TextBox" & i + 20).ForeColor = &H80000003 
                Me.Controls("TextBox" & i + 30).BackColor = &H80000005 
                Me.Controls("TextBox" & i + 30).ForeColor = &H80000003 
                 
            Else 
                Me.Controls("TextBox" & i).Enabled = False 
                Me.Controls("TextBox" & i + 10).Enabled = False 
                Me.Controls("TextBox" & i + 20).Enabled = False 
                Me.Controls("TextBox" & i + 30).Enabled = False 
                Me.Controls("TextBox" & i).BackColor = &H80000003 
                Me.Controls("TextBox" & i).Font.ColorIndex 
                Me.Controls("TextBox" & i + 10).BackColor = RGB(255, 0, 0) 
                Me.Controls("TextBox" & i + 10).ForeColor = RGB(255, 0, 0) 
                Me.Controls("TextBox" & i + 20).BackColor = &H80000003 
                Me.Controls("TextBox" & i + 20).ForeColor = &H80000010 
                Me.Controls("TextBox" & i + 30).BackColor = &H80000003 
                Me.Controls("TextBox" & i + 20).ForeColor = &H80000010 
            End If 
        Next 
    End Sub 
    
    
    Formatting tags added by mark007
    VB:
    Me.Controls("TextBox" & i + 10).ForeColor = RGB(255, 0, 0) 
    
    
    Formatting tags added by mark007
    this is not working on disable ..on enable it is ok. so, What it is wrong?

  2. #2
    Administrator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,000
    Location
    It might help if you uploaded an example file so that we don't have to build one here....
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    please, look in attachment. thx

  4. #4
    Administrator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,000
    Location
    Hi there,

    I'm not sure I quite follow what's not working here. I tried inserting the line of code you gave above, and it is working, although not in all cases. (Works on checkbox 1,2, but not some of the others.) Honestly, I haven't had time to look into it more deeply.

    Can you be a little more clear on what isn't happening?
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  5. #5
    (check box) and the rest of the code is in sketch zone (so that one, it is not important) ..in what I am interested, it is just the color of the disable text.box. wen the text box is disable the color of the text it is ALLAYS gray with shadow (whatever I try to wright there in the code, the color remains the same (gray)) I like to put another color or to take out the shadow.

    I am using Win Xp an excel 2003

  6. #6
    Administrator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,000
    Location
    Okay, that makes sense. I did have a fool around with it last night, and I see what you mean about the grey text. I can't see a text.color property at all for the textbox though. My suggestion would be to set up some more text boxes and hide them (either behind your current textboxes or off the side of the userform). Then in your disable code you can write the values to the secondary text boxes and clear out the first.

    Not perfect, but hopefully should work...
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  7. #7
    ok, I will see (for the moment, I will let it like this), thx for your time.

Posting Permissions

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