I admit, the headline is exaggerated, just to attract attention. Here are only the preview codes for Word documents and Excel documents.
Word:
//This part of the source:http://princed.mblogger.cn/posts/11885.aspx
//uses ActiveX;
procedureTform1.menupreviewclick (Sender:tobject);
var
Ioo:ioleinplaceobject;
begin
Olecontainer1.doverb (ovshow);
ifOlecontainer1.stateinch[Osuiactive] Then
begin
OleContainer1.OleObjectInterface.QueryInterface (IOLEINPLACEOBJECT,IOO);
IOO. Uideactivate;
IOO: =nil;
End;
OleContainer1.OleObject.PrintPreview;
Olecontainer1.doverb (ovshow);
Olecontainer1.align: = olecontainer1.align;
End;
Excel:
Excel can display the preview window by changing the OleContainer1.OleObject.PrintPreview to OleContainer1.OleObject.ActiveSheet.PrintPreview, but the preview form is a bit more serious and the program There is no response.
The correct approach is to:
procedure Tform1.menupreviewclick (Sender:tobject);
Var
Excelapp:variant;
Begin
Excelapp: = Createoleobject (' Excel.Application ');
ExcelApp.WorkBooks.Open (filename{file name} );
Excelapp.visible:=true;
ExcelApp.ActiveSheet.PrintPreview;
ExcelApp.WorkBooks.Close;
Excelapp.quit;
End;
http://blog.csdn.net/nhconch/article/details/497352
Preview Office Documents with programs