Solved

vb 6 writing to excel

Posted on 2000-03-07
13
216 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

809 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