Solved

vb 6 writing to excel

Posted on 2000-03-07
13
217 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

679 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