Solved

vb 6 writing to excel

Posted on 2000-03-07
13
215 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now