вот, если вдруг надо кому...
Код:
procedure TestMacroProc (MName:string; AParams:TObject);
var
wPrm:TmParams;
ds:Tdataset;
zap:string;
bl:TBLObfield;
begin
wPrm:=AParams as TmParams;
if wPrm.Values[1]=1 then zap:='select image from dent_teeth_map where map_id='+wPrm.Values[0]
else zap:='select template from templates where id=747';
ds:=CreateSQLDataset(zap,true);
bl:= ds.fields[0] as tblobfield;
if wPrm.Values[1]=1 then bl.savetofile('c:\1.gif')
else bl.savetofile('c:\1.txt');
end;
creatdataset это нестандартная процедура, но если вы сможете сделать свой то это прокатит)