Solved

vb 6 writing to excel

Posted on 2000-03-07
13
214 Views
Last Modified: 2010-05-02
This is the code that i use to write to an excel worksheet, my question is how can i set the cell properties so that the back ground color is used.
I've tried backcolor and it did not work.
        xlobj.Worksheets(1).Cells(Rows, 1).Value = rstPipe1.Fields("RecDate")
        xlobj.Worksheets(1).Cells(Rows, 2).Value = rstPipe1.Fields("ReferralContact")
        xlobj.Worksheets(1).Cells(Rows, 3).Value = rstPipe1.Fields("BusinessType")

xlobj.worksheets(1).range(A1:A14).backcolor = somecolor  
this does not work.

any suggestions.

thanx

0
Comment
Question by:jtjcomp
  • 6
  • 4
  • 3
13 Comments
 
LVL 9

Expert Comment

by:samopal
ID: 2592733
set oRange = xlobj.worksheets(1).range(A1:A14).select
oRange.ColorIndex = YourColor

HTH
0
 
LVL 9

Expert Comment

by:samopal
ID: 2592742
Sorry, last line should be

oRange.Interior.ColorIndex = YourColor

0
 
LVL 1

Author Comment

by:jtjcomp
ID: 2592826
This is the line i used
    xlobj.Worksheets(1).Range("A1:N14").Interior.ColorIndex = vbBlue
and it gave me error 1004 unable to set the colorindex property of the interior class,


any suggestions as to why
0
 
LVL 9

Expert Comment

by:samopal
ID: 2592862
Hmm... Try this:

xlobj.worksheets(1).range(A1:A14).select
xlobj.worksheets(1).selection.Interior.ColorIndex = vbBlue
 
I remember that I did it. But now I haven't Excel installed...
0
 
LVL 1

Author Comment

by:jtjcomp
ID: 2593028
no, that did not work either.
0
 
LVL 1

Author Comment

by:jtjcomp
ID: 2597716
That is not working i will reopen the question and see if there  are any other suggestions.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Accepted Solution

by:
dalbello earned 100 total points
ID: 2599784
Try this
xlobj.Worksheets(1).Range("A1:A14").Interior.ColorIndex = 5

(0 = default, 1 = black, 2 = white,  3 = red, 4 = green, 5 = blue .... etc ... you can test )
0
 
LVL 1

Author Comment

by:jtjcomp
ID: 2601221
Using a number for the colorindex work!
Thanx for your help, Both of you.

0
 

Expert Comment

by:dalbello
ID: 2601298
jtjcomp
I'm happy to help you.
Thank you.
0
 

Expert Comment

by:dalbello
ID: 2601301
jtjcomp
I'm happy to help you.
Thank you.
0
 

Expert Comment

by:dalbello
ID: 2601307
jtjcomp
I'm happy to help you.
Thank you.
0
 

Expert Comment

by:dalbello
ID: 2601313
jtjcomp
I'm happy to help you.
Thank you.
0
 

Expert Comment

by:dalbello
ID: 2601342
Thanks !
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now