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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems sizing chart area

Status
Not open for further replies.

greggb

Programmer
Dec 6, 2003
30
US
I am having a heck of a time trying to size a simple pie chart in Excel using VFP. This should be simple but I think it is a case of not knowing the proper VFP commands. Here is what the excel macro gives:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Chart 1").ScaleWidth 1.12, msoFalse, _
msoScaleFromBottomRight

How do I convert this to VBA? For some reason it never finds the "shapes" I identify (Chart 1)

Can someone help me?

Thanks.
 

How do I convert this to VBA? [/code]

If this is a recorded macro in Excel, the code IS VBA. Or did you mean something else.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

I've tried every variation of this code I can think of but it doesn't work for some reason. Sometimes I have problems converting VBA to VFP because it isn't EXACTLY the same.

Maybe you could give me a small sample of how to resize a chart in VFP code? My main goal is to resize the plot area but you can only resize it as big as the chart is; so you have to resize the chart. Also, I think that if I got this part, I could crop it.

Thanks.
 
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveSheet.Shapes("Chart 1").ScaleWidth 1.12, msoFalse, _
msoScaleFromBottomRight

I see three issues with the code. On the last line, you need a bracket at scaleWidth, and I would assume that msoFalse and msoScaleFromBottomRight and not defined. Unlike VBA, VFP does not know that values of these.




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
HHmmmm... Now it says "unable to get ChartObjects property of the worksheet class"

This seems so simple yet for some reason....

 

Try accessing your chart using this (If you only have one chart.
Code:
oWorkbook.ActiveChart.select

Skip this line
Code:
ActiveSheet.ChartObjects("Chart 1").Activate



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
..I hate to keep bothering you with this but...

I accessed the chart. Now it says that "the item with the specified name cannot be found". In the debugger, the name of the chart definately says "Chart 1". This is the major problem I was having with this all night.

Here is my code:

oSheet.Shapes("Chart 1").ScaleWidth=1.12
 
Are you sure you have the correct object name ("Chart 1")? The way to tell is to deselect the object, record a new macro, select the object, stop recording, then view the macro code and see what it's called.

Once you've checked that, try this:
oSheet.Shapes("Chart 1").ScaleWidth(1.12)

-Jessica
 
Sorry, actually, the syntax should be something like:

.ScaleHeight(1.33, 0, 1)
.ScaleWidth(1.33, 0, 1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top