Excel OLE chart generation

  • Thread starter Thread starter Una
  • Start date Start date

Una

Una

Associate
Joined
26 Nov 2004
Posts
2,471
Location
Reading / Lake District
I am currently using a perl script with Win32::OLE::Const module to generate a graph in Excel.

For example
Code:
 # Create an excel object
  my $excel = CreateObject OLE 'Excel.Application' or die $!;

  $excel->{'Visible'} = 1;

  # Open a new workbook
  my $workbook = $excel -> Workbooks -> Add;

  # Select the first sheet in the workbook
  my $sheet = $workbook -> Worksheets(1);

  # Name the sheet according to the test we are charting
  $sheet ->{Name} = $parms->{test};

Then creating a chart:

Code:
# Create a chart based on the selected results
  my $Chart = $excel->Charts->Add;

What I want to be able to do is to set the height and the width of the chart. I.e I need the names of the properties that set that.

I can't seem to find any documentation on this, so I was wondering if someone with VB or something with intellisense could look up the property name for me.
 
In a macro it would be:

Code:
Sub RecordedAddChartObject()
    Charts.Add
    ActiveChart.ChartType = xlXYScatterLines
    ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A3:G14")
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
End Sub

or, hence:

Code:
Sub ResizeAndRepositionChart()
    ' The ChartObject is the Chart's parent
    With ActiveChart.Parent
        .Left = 100
        .Width = 375
        .Top = 75
        .Height = 225
    End With
End Sub
 
Back
Top Bottom