Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a Chart
Message
From
20/07/2011 15:00:17
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01518660
Message ID:
01518692
Views:
45
>>Hi Boris,
>>
>>unfortunately I am using Office XP and don't have 2007 around. I tried recording a macro, but I can't see how to change the chart size.
>
>
>http://peltiertech.com/Excel/ChartsHowTo/ResizeAndMoveAChart.html

Thanks, but I can't get that to work :( If I had any hair it would all have been pulled out by now!

Here's what I tried:
LOCAL loxl as EXCEL.Application

m.loxl = CREATEOBJECT("Excel.application")
m.loXLWorkbook = m.loxl.Workbooks.Add()
m.loxl.Visible = .t.

m.loXL.ActiveSheet.Cells[1,1].VALUE = "Month"
m.loXL.ActiveSheet.Cells[2,1].VALUE = "Jan"
m.loXL.ActiveSheet.Cells[3,1].VALUE = "Feb"
m.loXL.ActiveSheet.Cells[4,1].VALUE = "Mar"
m.loXL.ActiveSheet.Cells[5,1].VALUE = "Apr"
m.loXL.ActiveSheet.Cells[6,1].VALUE = "May"

m.loXL.ActiveSheet.Cells[1,2].VALUE = "Claims"
m.loXL.ActiveSheet.Cells[1,3].VALUE = "Turnaround"

FOR i = 2 TO 6
	m.loXL.ActiveSheet.Cells[m.i,2].VALUE = m.i * 10
	m.loXL.ActiveSheet.Cells[m.i,3].VALUE = m.i - 1
ENDFOR
m.loSourceRange = m.loXL.Range("A1:C6")
m.loSourceRange.Select()

xlBuiltIn = 21
xlColumns = 2
xlLocationAsObject = 2
xlCategory = 1
xlPrimary = 1
xlValue = 2
xlSecondary = 2
xlUp = -4162
xl3DPie = -4102
xlLineMarkers = 65
xlLocationAsNewSheet = 1

m.loChart = m.loXLWorkbook.Charts.Add()

				
*!*	m.loChart.ChartWizard(m.loSourceRange,  -4102, 4 , 2, 1, 0, .T., [Claims Received/Turnaround])
m.loChart.ApplyCustomType(xlBuiltIn, "Lines on 2 Axes")
m.loChart.HasTitle = .t.
m.loChart.ChartTitle.Characters.Text = "Claims Received/Turnaround"
m.loChart.Axes(xlCategory, xlPrimary).HasTitle = .T.
m.loChart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
m.loChart.Axes(xlValue, xlPrimary).HasTitle = .T.
m.loChart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Claims Received"
m.loChart.Axes(xlCategory, xlSecondary).HasTitle = .T.
m.loChart.Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text = ""
m.loChart.Axes(xlValue, xlSecondary).HasTitle = .T.
m.loChart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Avg. Turnaround"

With m.loChart.Axes(xlCategory)
    .HasMajorGridlines = .F.
    .HasMinorGridlines = .F.
EndWith
With m.loChart.Axes(xlValue)
    .HasMajorGridlines = .T.
    .HasMinorGridlines = .F.
ENDWITH
m.loChart.Location(xlLocationAsNewSheet)
m.loChart.Parent.Height = 100 
m.loChart.Parent.Width = 100
m.loXL.Visible = .T.
The important lines are the third and second to last ones. I get an error: OLE rrror code 0x80020006: Unknown name.

I tried referencing it like this:
FOR j = 1 TO m.loXL.ActiveSheet.Shapes.Count
	If m.loXL.ActiveSheet.Shapes(j).Type = msoChart Then
		m.loXL.ActiveSheet.Shapes(j).Width = 4 * 72
		m.loXL.ActiveSheet.Shapes(j).Height = 3 * 72
	EndIf
ENDFOR
but the count is 0!
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform