change Excel Cell Forecolor using VB6
Greetings. The version that I have writtin using LISTVIEW is working very well. I have another interesting problem which is beyong my knowledge. I have been asked to display in the Excel Cell forecolor in RED and not the backcolor if the exported data from ACCESS Sales Table whose sales value did not meet certain value.
this script is not working:
objWorksheet.Cells(intRow, intCol).Fill.Schemecolor = vbRed
Here is part of the overall VB6 script that I have written
Do Until .EOF
intCol = 0
intRow = intRow + 1
For i = 0 To (.Fields.Count - 1) Step 1
intCol = intCol + 1
objWorksheet.Cells(intRow, intCol) = .Fields(i).Value
If .Fields("SalesAmt").Value < 500 Then
objWorksheet.Cells(intRow, intCol).Fill.Schemecolor = VbRed
Excel's macro recorder is your friend. Begin recording a macro, then manually perform the action(s) you wish to automate -- in this case, changing the forecolor of a cell -- then look at the code that was recorded. Try this:
objWorksheet.Cells(intRow, intCol).Font.Color = vbRed
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Last Post: 02-22-2008, 09:42 AM
By Nick313 in forum VB Classic
Last Post: 11-15-2007, 03:16 PM
By Ifgash in forum VB Classic
Last Post: 04-23-2006, 02:58 AM
Last Post: 01-08-2002, 03:54 AM
By Phil in Austin in forum .NET
Last Post: 02-08-2001, 12:21 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL