LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change series or line color in excel 2007 using ActiveX

I am trying to change series color using Excel 2007 with ActiveX as below. It seems the color cannot be controlled correctly. For example, if I chosse red color, my curve will be changed to blue. Any ideas?

 

Also, I googled and found a guy ran into similiar problem using VBA for Excel 2007. See the link below:

 

http://help.wugnet.com/office/change-series-line-color-excel-2007-vba-ftopict1062646.html

 

 

Set ch = Worksheets("Chart").ChartObjects(1)
Set objSeries = ch.Chart.SeriesCollection(1)
objSeries.Format.Line.ForeColor.RGB = RGB(255, 127, 0)

 

According to the post, it need to be done as follows

objSeries.Border.Color = RGB(255, 127, 0) . But I cannot find the border property/method in ActiveX.

LineColor.PNG

 

 

 

The color seems to be abitrary. and I found the

 

0 Kudos
Message 1 of 15
(7,255 Views)

Xubuli,

 

I looked into your question and confirmed that Border.Color is not located under the Excel.Series library. Instead, you must locate it under _Worksheet.UsedRange as seen below in the figure. I am attaching the VI file where I located the the Border.Color property node, and I am also including a SubVI on the block diagram that goes into explicitly set the cell color and border. This SubVI can be found under Programming>>Report Generation>>Excel Specific>>Excel Format>>Excel Set Cell Color and Border.vi, if you have the Report Generation Toolkit installed. I hope this helps.

 

Border_Color.png

 

Larry H

Applications Engineer
National Instruments
0 Kudos
Message 2 of 15
(7,206 Views)

Xubuli,

 

have you found a solution to this problem?? I have been wasting the best part of the last two days to solve this but no luck..

 

Thanks a lot,

Harry

0 Kudos
Message 3 of 15
(6,954 Views)

Here is how we did it. We also created a color changer as the colors for LabVIEW are different thatn the colors for Excel.

 

Something else that you need to think about is that if you have a white color plot you need to change it in Excel if you are not making the graph background color something other than white.

 

Example.png

Tim
GHSP
Message 4 of 15
(6,951 Views)

Tim, 

 

thanks a lot.. Sorted.. These excel activex sequences can be a pain sometimes..

 

Harry

0 Kudos
Message 5 of 15
(6,945 Views)

 

I'm confused.  I am trying to change the line color on a chart in excel using activex.  I have been able to change the marker colors but not the lines.

I don't understand how Tim is getting Border as an option under Series property node.  I don't have that as an option.  Instead, I have tried changing the format, but it isn't working.

 

Excel 2007

What is wrong with this?

 

0 Kudos
Message 6 of 15
(6,740 Views)

Hi,

 

I have attached the VI I made for plotting multi-curve graphs with configurable line and marker colours in Excel 2010.. I am pretty sure it should also work for excel 2007, too. FYI, In case you dont already know, excel 2007 has limitations with respect to maximum number of data cols and rows..

 

Apologies for not giving a more general example but its been a while now and this active-x thingy looks again pretty alien to me.. This VI includes lots of additional parameters which are useless to you but I have highlighted the part you are interested at, somewhere in the centre of the back panel.

 

Hopefully this will be of some help.. Open with LV 2009 or later.

 

Cheers,

Harry

0 Kudos
Message 7 of 15
(6,721 Views)

 


@whatmorereason wrote:

 

I'm confused.  I am trying to change the line color on a chart in excel using activex.  I have been able to change the marker colors but not the lines.

I don't understand how Tim is getting Border as an option under Series property node.  I don't have that as an option.  Instead, I have tried changing the format, but it isn't working.

 

Excel 2007

What is wrong with this?

 



There is apparently a bug in Excel 2007.

 

The discussion with solution over at Microsoft forum. http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/2816660e-a18e-47f4-b121-02a71cb2c262

 

In LabVIEW, the solution would translate to

 

excel2007.jpg

 

0 Kudos
Message 8 of 15
(6,715 Views)

Thanks for the advice.

However, the variant to data conversion at the series select to border causes a type mismatch.

Any ideas?

0 Kudos
Message 9 of 15
(6,708 Views)

I don't have a Chart to try this on.

 

You'll have to try different things to get it the LabVIEW code to match the C# code.

 

 

 

 

0 Kudos
Message 10 of 15
(6,706 Views)