Can anyone shed some light on why I would get an access violation using the following code?

for t := 0 to ComponentCount-1 do
begin
s := Components[t].Name;
st := Copy(s,Length(s)-4,Length(s));
if (st='Graph') then
begin
fn := Copy(s,1,Length(s)-5)+'.bmp';
try
TChart(Components[r]).SaveToBitmapFile(fn);
finally

end;
end;
end;


Essentially what the code does is loop through all components in the current scope and if a component name ends in Graph the idea is to save it as a Bitmap file. all goes well until I execute the savetobitmapfile method when I get an access violation