Solved

vb 6 writing to excel

Posted on 2000-03-07
13
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

738 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