Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using JS to Create an Excel Chart

Status
Not open for further replies.

KevinFSI

Programmer
Nov 17, 2000
582
US
I have an EXCEL workbook that I've created using JavaScript and ActiveX. So far everything has gone well. One of the worksheets is a chart. Things have gone well there too. I have one problem though. When setting the one of the bars on the chart to a pattern rather than a color, I get stuck. Here is how the line appears as VBA:
Code:
Selection.Fill.Patterned Pattern:=msoPatternShingle

I have tried several different ways to translate this to JS, but haven't had ANY luck. (Note xlApp is my excel object) Here are the various ways I've tried this.
Code:
xlApp.Selection.Fill.Patterned(47);
xlApp.Selection.Fill.Patterned = 47;
xlApp.Selection.Fill.Patterned(null);
xlApp.Selection.Fill.Patterned(msoPatternShingle);
xlApp.Selection.Fill.Patterned = msoPatternShingle;
xlApp.Selection.Fill.Patterned.msoPatternShingle = true;

I'm about to lose it! PLEASE HELP ME!

Kevin
slanek@ssd.fsi.com

"Life is what happens to you while you're busy making other plans."
- John Lennon
 
xlApp.Selection.Fill.Patterned = 'msoPatternShingle';

msoPatternShingle is a CONST in VBA, ie it can be used interchangeable with a certain number. JS doesn't have the same CONST declaration so you need quotes to stop JS trying to interpret it as some vairable you've forgotten to assign a value to.
 
Still a nogo. Check out this block of code.
Code:
xlWb.ActiveChart.SeriesCollection(4).Select();
xlApp.Selection.Border.Weight = 2;
xlApp.Selection.Border.LineStyle = -4105;
xlApp.Selection.Shadow = false;
xlApp.Selection.Fill.Patterned = 'msoPatternShingle';
xlApp.Selection.Fill.Visible = true;
xlApp.Selection.Fill.ForeColor.SchemeColor = 17;
xlApp.Selection.Fill.ForeColor.SchemeColor = 2;
The 'msoPatternShingle' line is the only one that throws an error. If I drag this entire block into the watch window in debugger, the 'mso...' line says "Object doesn't support this property or method."

Kevin
slanek@ssd.fsi.com

"Life is what happens to you while you're busy making other plans."
- John Lennon
 
You would think.

If you look at msoPatternShingle in the Object Browser in the VB editor in Excel, you'll see the value for msoPatternShingle is 47, which is why, in my original post, there are several references to the number 47.

Kevin
slanek@ssd.fsi.com

"Life is what happens to you while you're busy making other plans."
- John Lennon
 
weird???
may be its the calling convention used?
dont suppose you are meant to use a set statement?
 
I know really nothing about this, but it seems that you have two parameters that you need to worry about. The first being that the fill is to be a pattern. And the second is the value of the pattern.

Again - I may be barking up the wrong tree - in the wrong neighborhood.

Einstein47
("As a cure for worrying, work is better than whiskey." - Thomas Edison)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top