var
ADevice, ADriver, APort: String;
ADeviceMode: THandle;
//DevMode: PDeviceMode; MSWord: Variant;
WordDoc:Variant;
Save_Cursor:TCursor;
TempletFile:String;
BookMarkName:String; //reOther: TRichEdit;
StrFileName:String;
FSearchRec:TSearchRec;
FindResult:Integer;
StrFindFile:String;
begin TempletFile:='FixSafeTechRpt.dot';
Save_Cursor:= Screen.Cursor;
Screen.Cursor := crHourGlass; SetLength(ADevice, 255);
SetLength(ADriver, 255);
SetLength(APort, 255); if ADeviceMode = 0 then
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(PChar(ADevice), PChar(ADriver), PChar(APort), ADeviceMode);
end; if ADeviceMode = 0 then
begin
Screen.Cursor := Save_Cursor;
ShowMessage('系统中没有安装打印机,无法打印');
exit;
end; try
//reOther:=
try
MSWord := CreateOLEObject('Word.Application');
except
Screen.Cursor := Save_Cursor;
ShowMessage('您的系统中没有安装Office,所以无法打印');
exit;
end;
MsWord.Visible := False;
TempletFile:=ExtractFilePath(Application.ExeName)+TempletPath+TempletFile;
MSWord.Documents.Add(TempletFile, False);
WordDoc:=MsWord.ActiveDocument;
//这里使用了书签
BookMarkName:='PrjID';
WordDoc.Application.Selection.goto(What:= wdGoToBook, Name := BookMarkName);
WordDoc.Application.Selection.Text :=PrjMessList.Strings[0];
WordDoc.PrintOut;
Screen.Cursor := Save_Cursor;
Application.MessageBox ('打印完毕后点确定按钮', '打印信息', MB_OK);
WordDoc.close(False);
MSWord.quit;
except
WordDoc.close(False);
MSWord.quit;
ShowMessage('不可知原因,无法生成打印报表');
exit;
end;
ADevice, ADriver, APort: String;
ADeviceMode: THandle;
//DevMode: PDeviceMode; MSWord: Variant;
WordDoc:Variant;
Save_Cursor:TCursor;
TempletFile:String;
BookMarkName:String; //reOther: TRichEdit;
StrFileName:String;
FSearchRec:TSearchRec;
FindResult:Integer;
StrFindFile:String;
begin TempletFile:='FixSafeTechRpt.dot';
Save_Cursor:= Screen.Cursor;
Screen.Cursor := crHourGlass; SetLength(ADevice, 255);
SetLength(ADriver, 255);
SetLength(APort, 255); if ADeviceMode = 0 then
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(PChar(ADevice), PChar(ADriver), PChar(APort), ADeviceMode);
end; if ADeviceMode = 0 then
begin
Screen.Cursor := Save_Cursor;
ShowMessage('系统中没有安装打印机,无法打印');
exit;
end; try
//reOther:=
try
MSWord := CreateOLEObject('Word.Application');
except
Screen.Cursor := Save_Cursor;
ShowMessage('您的系统中没有安装Office,所以无法打印');
exit;
end;
MsWord.Visible := False;
TempletFile:=ExtractFilePath(Application.ExeName)+TempletPath+TempletFile;
MSWord.Documents.Add(TempletFile, False);
WordDoc:=MsWord.ActiveDocument;
//这里使用了书签
BookMarkName:='PrjID';
WordDoc.Application.Selection.goto(What:= wdGoToBook, Name := BookMarkName);
WordDoc.Application.Selection.Text :=PrjMessList.Strings[0];
WordDoc.PrintOut;
Screen.Cursor := Save_Cursor;
Application.MessageBox ('打印完毕后点确定按钮', '打印信息', MB_OK);
WordDoc.close(False);
MSWord.quit;
except
WordDoc.close(False);
MSWord.quit;
ShowMessage('不可知原因,无法生成打印报表');
exit;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货