DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting a Report

Hi

 

Im attempting to populate some  report charts with waveforms via a script (the report is a pre-build template I have created).

 

To generate the code I manualy populated the chart, then right click->copy as script. When i try to re-run it it come up wiht an error. The offending code is:

'Set o2DLine = Report.Sheets("Intoduction").Objects("2DAxis1").Curves2D.Item(1).Shape
Set o2DLine = o2DAxisSystem.Curves2D.Item(1).Shape
o2DLine.XChannel.Reference = ""
o2DLine.YChannel.Reference = "[1]/channel name"

 

The error being:

"The index "1" is ouside valid range"

 

referencing the 2nd line in the above code.

 

Any ideas on why this is occuring and how I can prevent it?

Cheers

0 Kudos
Message 1 of 2
(3,029 Views)

Hi,

 

remember that you need to define some variables, for instance:

Dim o2DAxisX1, o2DAxisX2, o2DAxisX3

Here you have an example how to setup the report and axes:

Call Report.Refresh
  Report.Settings.ImageExport.PNG.BitsPerPixel = 3
  Report.Settings.ImageExport.PNG.UseRatio     = False
  Report.Settings.ImageExport.PNG.Height       = 2800
  Report.Settings.ImageExport.PNG.Width        = 2000

  Set o2DAxisX1 = Report.Sheets("ChipTemperature_first_5_slots").Objects.Item("Slot01").XAxis.Scaling
  o2DAxisX1.AutoScalingType = eAxisAutoScalingCompleteAutomatic
  Set oCurveLegend = Report.Sheets("ChipTemperature_first_5_slots").Objects.Item("Slot01").CurveLegend
  oCurveLegend.Columns.Item(1).Text = ("Speaker_" & speaker(1))
  Set o2DAxisX2 = Report.Sheets("ChipTemperature_first_5_slots").Objects.Item("Slot02").XAxis.Scaling
  o2DAxisX2.AutoScalingType = eAxisAutoScalingCompleteAutomatic
  Set oCurveLegend = Report.Sheets("ChipTemperature_first_5_slots").Objects.Item("Slot02").CurveLegend
  oCurveLegend.Columns.Item(1).Text = ("Speaker_" & speaker(2))

Here you have an example how to export it as an image:

Call Report.Sheets("ChipTemperature_first_5_slots").ExportToImage(graphspath & "\" & "Chip_Temperature_first_5_slots_whole_period" & ".PNG",eImageExportTypePNG)

In above code I have some variables, but I left them intentionally, just to show you that you can glue them together in order to do some things in loops, etc. You need to just put the path, name of the file and extension.

In your case it looks like you forgot to define variable for 2DAxis1.

0 Kudos
Message 2 of 2
(2,946 Views)