Preview Office Documents with programs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.