Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Transfer colour from Excel to VB form

Posted on 2003-03-17
3
Medium Priority
?
174 Views
Last Modified: 2010-05-03
I would like to get my VB program (VB5) to 'read' the background colour of a cell in Excel and then change the background colour of a label on a VB form to the same colour.

The following code has changed the label's colour, but not to the right one!

lblExample.BackColor = wkbExample.Worksheets("Example").Cells(1, 1).Interior.ColorIndex

If anyone has any suggestions then I would be very grateful.
Thanks.
0
Comment
Question by:DudBug
  • 3
3 Comments
 
LVL 3

Expert Comment

by:DocM
ID: 8154507
Hy,
See The 56 Excel Colors - Color Palette - RGB equivalence
at  
http://www.geocities.com/davemcritchie/excel/colors.htm
0
 
LVL 3

Expert Comment

by:DocM
ID: 8154646
Hy,
See The 56 Excel Colors - Color Palette - RGB equivalence
at  
http://www.geocities.com/davemcritchie/excel/colors.htm
0
 
LVL 3

Accepted Solution

by:
DocM earned 80 total points
ID: 8154663

Instead of the colorindex property, use the color property.

lblExample.BackColor = wkbExample.Worksheets("Example").Cells(1, 1).Interior.Color which will give the RGB color value.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question