Link to home
Start Free TrialLog in
Avatar of jtjcomp
jtjcomp

asked on

vb 6 writing to excel

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

Avatar of samopal
samopal

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

HTH
Sorry, last line should be

oRange.Interior.ColorIndex = YourColor

Avatar of jtjcomp

ASKER

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
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...
Avatar of jtjcomp

ASKER

no, that did not work either.
Avatar of jtjcomp

ASKER

That is not working i will reopen the question and see if there  are any other suggestions.
ASKER CERTIFIED SOLUTION
Avatar of dalbello
dalbello

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jtjcomp

ASKER

Using a number for the colorindex work!
Thanx for your help, Both of you.

jtjcomp
I'm happy to help you.
Thank you.
jtjcomp
I'm happy to help you.
Thank you.
jtjcomp
I'm happy to help you.
Thank you.
jtjcomp
I'm happy to help you.
Thank you.
Thanks !