Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.10.16;
Скачать: CL | DM;

Вниз

Системы поиска   Найти похожие ветки 

 
OlegS   (2003-10-05 16:36) [0]

Как работать с файлами MSWord напрямую тоесть извлечь из него информациию не открывая ворд?


 
Gigabyte ©   (2003-10-05 18:18) [1]

Какую именно информацию?
Можешь попробовать воспользоваться COM-Хранилищами
http://www.g299792458.boom.ru раздел "Мои Статьи"


 
me   (2003-10-06 13:23) [2]

Искать текст можно так:
uses ComObj, ActiveX, AxCtrls, SysUtils, Classes;
...
function FindTextInFile(const FileName, TextToFind: WideString): boolean;
var Root: IStorage;
EnumStat: IEnumStatStg;
Stat: TStatStg;
iStm: IStream;
Stream: TOleStream;
DocTextString: WideString;
begin
Result:=False;

if not FileExists(FileName) then Exit;

// Check to see if it"s a structured storage file
if StgIsStorageFile(PWideChar(FileName)) <> S_OK then Exit;

// Open the file
OleCheck(StgOpenStorage(PWideChar(FileName), nil,
STGM_READ or STGM_SHARE_EXCLUSIVE, nil, 0, Root));

// Enumerate the storage and stream objects contained within this file
OleCheck(Root.EnumElements(0, nil, 0, EnumStat));

// Check all objects in the storage
while EnumStat.Next(1, Stat, nil) = S_OK do

// Is it a stream with Word data
if Stat.pwcsName = "WordDocument" then

// Try to get the stream "WordDocument"
if Succeeded(Root.OpenStream(Stat.pwcsName, nil,
STGM_READ or STGM_SHARE_EXCLUSIVE, 0, iStm)) then
begin
Stream:=TOleStream.Create(iStm);
try
if Stream.Size > 0 then
begin
// Move text data to string variable
SetLength(DocTextString, Stream.Size);
Stream.Position:=0;
Stream.Read(pChar(DocTextString)^, Stream.Size);

// Find a necessary text
Result:=(Pos(TextToFind, DocTextString) > 0);
end;
finally
Stream.Free;
end;
Exit;
end;
end;

end.



Страницы: 1 вся ветка

Текущий архив: 2003.10.16;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.027 c
14-51427
petro
2003-09-26 11:30
2003.10.16
DSGNintf.dcu - что такое?


14-51411
CinCinNut
2003-09-26 13:23
2003.10.16
Видеопроекторы


1-51327
Soi
2003-10-06 06:54
2003.10.16
Регулярные выражения


3-51082
Filat
2003-09-25 19:32
2003.10.16
FIBPlis под Delphi 7, не могу установить :(((


1-51308
Samael6
2003-10-06 12:27
2003.10.16
Пакеры