1
General / Re: change details Office file !
« Last post by KodeZwerg on Today at 07:05:44 am »HiBy using Microsoft Office COM abilities.
please help and guide me
how can i change details office file ?
- program project1;
- {$APPTYPE CONSOLE}
- uses
- SysUtils, ComObj, ActiveX;
- procedure ExcelMetadata;
- var
- ExcelApp, Workbook, Worksheet: OLEVariant;
- begin
- ExcelApp := CreateOleObject('Excel.Application');
- try
- ExcelApp.Visible := False;
- // path MUST be absolute
- Workbook := ExcelApp.Workbooks.Open(ExtractFilePath(ParamStr(0)) + 'demo.xlsx');
- Worksheet := Workbook.Worksheets[1];
- WriteLn('Author: ' + Workbook.BuiltInDocumentProperties('Author').Value);
- WriteLn('By hitting return, Author name will be "Lazarus COM" !');
- ReadLn;
- Workbook.BuiltInDocumentProperties('Author').Value := 'Lazarus COM';
- Workbook.Save;
- Workbook.Close;
- finally
- ExcelApp.Quit;
- end;
- end;
- begin
- CoInitialize(nil);
- try
- ExcelMetadata;
- finally
- CoUninitialize;
- end;
- ReadLn;
- end.