PC -> Mac Excel color problem

P

Paul Dreyer

I am writing a tool in Excel 2000 on a PC, and one of the
VB subroutines I've written generates a spider chart and
colors the background light green (using
PlotArea.Interior.Color = RGB(170,255,13)). When I send
this to my project leader, who is running Excel 2004 on a
Mac, when he runs this subroutine, the background comes out
black. I've also tried setting the color using a
colorindex number, same problem. This has officially
exceeded my knowledge of the intricacies of PC/Mac
conversion in Excel. Any ideas? Much thanks in advance!


-- Paul
 
J

Jim Gordon MVP

Hi,

I recorded a macro that changes the background color. This works OK when
the plot area is manually selected first:
Sub colorbackground()
With Selection
.Fill.Visible = True
.Fill.ForeColor.RGB = RGB(170, 255, 13)
End With
End Sub

I modified it slightly to be close to your code and this also works:

Sub colorbackground()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
With Selection
.Interior.Color = RGB(170, 255, 13)
End With
End Sub

I wasn't able to duplicate the problem you had, but I don't know the
exact syntax that you used. If you post a little more of the code that
failed I'll give it a try and see what happens.

Thanks.

-Jim
 
P

Paul Dreyer

Hi, Jim.

Here is the code that is in there right now:

ActiveChart.PlotArea.Select
With Selection.Interior
.Color = RGB(170, 255, 113)
.PatternColorIndex = 1
.Pattern = xlSolid
End With

And again, the amazing thing is that this code gives me no
trouble on the PC, just the Mac. Weird.

Thank you for your help!
Paul
 
J

Jim Gordon MVP

Hi Paul,

I tried your code sample on a couple graphs and it worked just fine for me.

If you're getting errors, sometimes VBA will be flaky (both Mac and
Windows).

Things to try:
Copy your entire module code to a text editor (NotePad, TextEdit,
anything that does just text). Delete the module. Then make a new module
and paste the code back in.
You might try compiling your code to see where it stops. The code
will be highlighted and you'll at least know where a corrupt spot might
be. Even if that particular bit of code is OK, delete it and re-enter
it. Sometimes you can get away with that.

-Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top