home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / nastroje / d5 / 5EXCELRE.ZIP / START / OTCNASTR.PAS < prev    next >
Pascal/Delphi Source File  |  1999-10-29  |  3KB  |  112 lines

  1. unit Otcnastr;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Buttons, Report,DB, StdCtrls,
  8.   ExtCtrls, SHELLAPI,DBTables;
  9.  
  10. type
  11.   TForm_nastr = class(TForm)
  12.     SpeedButton1: TSpeedButton;
  13.     SpeedButton3: TSpeedButton;
  14.     SpeedButton5: TSpeedButton;
  15.     Report1: TReport;
  16.     OpenDialog1: TOpenDialog;
  17.     SaveDialog1: TSaveDialog;
  18.     rg1: TRadioGroup;
  19.     procedure SpeedButton5Click(Sender: TObject);
  20.     procedure SpeedButton1Click(Sender: TObject);
  21.     procedure SpeedButton3Click(Sender: TObject);
  22.     procedure FormCreate(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.     FileNamerpt : ShortString;
  26.     Function  WinExecAndWait(var Path : ShortString; Visibility : word) : word;
  27.     Function  WEWExcell(var Pth : ShortString; Visibility : word) : word;
  28.   end;
  29.  
  30. var  Form_nastr: TForm_nastr;
  31.  
  32. implementation
  33.  
  34. {$R *.DFM}
  35.  
  36. //Uses IniFiles;
  37.  
  38. procedure TForm_nastr.SpeedButton5Click(Sender: TObject);
  39. begin
  40.  Close
  41. end;
  42.  
  43. procedure TForm_nastr.SpeedButton1Click(Sender: TObject);
  44. begin
  45.  OpenDialog1.FilterIndex:=RG1.ItemIndex+1;
  46.  if OpenDialog1.Execute then
  47.    FileNamerpt  := OpenDialog1.FileName;
  48. end;
  49.  
  50. Function  TForm_nastr.WinExecAndWait(var Path : Shortstring; Visibility : word) : word;
  51. var  InstanceID : THandle;
  52. begin
  53.   { Try to run the application }
  54.   InstanceID := ShellExecute(0,nil,'wordrep.exe',@Path[1],nil,SW_HIDE); {WinExec(@Path,Visibility);}
  55.   if InstanceID < 32 then Result:= InstanceID // error
  56.   else begin
  57.     Repeat
  58.       Application.ProcessMessages;
  59.     until Application.Terminated ;
  60.     Result := 32;
  61.   end;
  62. end;
  63.  
  64. Function  TForm_nastr.WEWExcell(var Pth : ShortString; Visibility : word) : word;
  65. var InstanceID : THandle;
  66.     sd,ss      : ShortString;
  67. begin
  68.   Pth:=Pth+#0;
  69.   ss:=Pth;
  70.   ss:=ExtractFilePath(Paramstr(0));
  71.   {Path:=ExtractFileName(Path)+#0;}
  72.   GetDir(0,sd);
  73.   ChDir(ss);
  74.   InstanceID := ShellExecute(0,nil,'put_rep1.exe',@Pth[1],nil,SW_HIDE);
  75.   if InstanceID < 32 then Result := InstanceID { error }
  76.   else begin
  77.     Repeat
  78.       Application.ProcessMessages;
  79.     until Application.Terminated;
  80.     Result := 32;
  81.   end;
  82.   ChDir(sd);
  83. end;
  84.  
  85. procedure TForm_nastr.SpeedButton3Click(Sender: TObject);
  86. Const acTail:string[9]='reprptxls';
  87. Var i :integer;
  88.     ss:Shortstring;
  89. begin
  90.   ss :=  FileNamerpt;
  91.   i:=pos('.',ss);
  92.   if i>0 then ss:=copy(ss,1,i-1);
  93.   ss:=ss+'.'+Copy(acTail,RG1.ItemIndex*3+1,3)+#0;
  94.   case RG1.ItemIndex of
  95.   1: begin
  96.       Report1.ReportName :=  FileNamerpt ;
  97.       Report1.Run;
  98.       i:=32;
  99.      end;
  100.   0: i:=WinExecAndWait(ss,1);
  101.   2: i:=WEWExcell(ss,1);
  102.   end;
  103.   if i<32 then  Application.MessageBox('Error','Attention',mb_OK+mb_IconHand+mb_TaskModal);
  104. end;
  105.  
  106. procedure TForm_nastr.FormCreate(Sender: TObject);
  107. begin
  108.   FileNameRpt:=''
  109. end;
  110.  
  111. end.
  112.