Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Change BackColor of embed forms.checkbox.1 when Value = True


Reply
 
Thread Tools Display Modes
  #1  
Old 05-01-2009, 08:06 PM
blueboundaries blueboundaries is offline
Newcomer
 
Join Date: May 2009
Posts: 1
Default Change BackColor of embed forms.checkbox.1 when Value = True


I'd like for when you click on an embedded checkbox in excel

[ =EMBED("Forms.CheckBox.1","") ]

for the BackColor to change to a different color.

Example:

Private Sub ssp1_Click()
If Value = True Then Set BackColor = HC0C0C0
End
If Value = False Then Set BackColor = HFFFFFF
End
End Sub

Can you please tell me what more code I have to use?
Reply With Quote
  #2  
Old 05-02-2009, 06:08 PM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Hi blueboundaries,

Welcome to the forum.

To do this, you will need to handle the Checkbox.Click event. Double-click on your Checkbox while in design mode and the following stub will be automatically created in VBA for you:

Code:
Private Sub CheckBox1_Click()

End Sub
You would then want to check the Me.CheckBox1.Value and set the Me.CheckBox1.BackColor property accordingly:

Code:
Private Sub CheckBox1_Click()
    If Me.CheckBox1.Value = True Then
        Me.CheckBox1.BackColor = &HC0C0C0
    Else
        Me.CheckBox1.BackColor = &HFFFFFF
    End If
End Sub
-- Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->