Author Topic: excel and word automation . Help me  (Read 258 times)

Packs

  • Hero Member
  • *****
  • Posts: 508
excel and word automation . Help me
« on: August 07, 2026, 04:20:36 am »
Hi everyone,

I'm looking to learn how to automate Microsoft Excel and Word using COM/OLE Automation in Lazarus (Free Pascal).

If anyone has any tutorials, sample projects, documentation, or working examples demonstrating how to create and use Excel or Word COM objects from Lazarus, I would really appreciate it if you could share them.

Thank you in advance for your help!

ADMGNS

  • Jr. Member
  • **
  • Posts: 90
  • keep it simple and smart
Re: excel and word automation . Help me
« Reply #1 on: August 07, 2026, 05:04:13 am »
only for Windows

Code: Pascal  [Select][+][-]
  1. uses
  2.   .., ComObj, ActiveX;
  3.  
  4. var
  5.   myWordApp, myWordDoc: OleVariant;
  6.   filename, ext: string;
  7. ...
  8.  
  9. if FileExists(filename) then
  10. begin
  11.   try
  12.     myWordApp := CreateOleObject('Word.Application');
  13.     myWordApp.Visible := True;
  14.     myWordDoc := myWordApp.Documents.Open(filename);
  15.     myWordApp.WindowState := 1; // 1: wdWindowStateMaximize
  16.   except
  17.     on E: Exception do
  18.     begin
  19.       ShowMessage(Format('%s. Word.Application cannot create', [ E.Message ]));
  20.       Exit;
  21.     end;
  22.   end;
  23. end;
  24.  

Packs

  • Hero Member
  • *****
  • Posts: 508
Re: excel and word automation . Help me
« Reply #2 on: August 07, 2026, 05:39:57 am »
Thank you.
This will through pascal. I want to make addins inside word.


CM630

  • Hero Member
  • *****
  • Posts: 1788
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: excel and word automation . Help me
« Reply #3 on: August 07, 2026, 09:06:14 am »
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018