Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 1725|回复: 0

使用lazarus打开office文件的方法

[复制链接]

该用户从未签到

发表于 2013-4-2 14:22:47 | 显示全部楼层 |阅读模式
  1. program TestMsOffice;

  2. {$IFDEF FPC}
  3. {$MODE Delphi}
  4. {$ELSE}
  5. {$APPTYPE CONSOLE}
  6. {$ENDIF}

  7. uses
  8.   SysUtils, Variants, ComObj;

  9. const
  10.   ServerName = 'Word.Application';
  11. var
  12.   Server     : Variant;
  13. begin
  14.   if Assigned(InitProc) then
  15.     TProcedure(InitProc);

  16.   try
  17.     Server := CreateOleObject(ServerName);
  18.   except
  19.     WriteLn('Unable to start Word.');
  20.     Exit;
  21.   end;

  22.    {Open existing document}  //Substitute your path and doc
  23.   Server.Documents.Open('c:\my\path\mydoc.doc');

  24.   Server.Visible := True;  {Make Word visible}

  25. end.
复制代码
回复

使用道具 举报

*滑块验证:

本版积分规则

QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

GMT+8, 2025-5-2 21:21 , Processed in 0.024889 second(s), 10 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表