Board index » delphi » How I can save a WORD Document in a Blob Field

How I can save a WORD Document in a Blob Field

Hello friends

     I see an application in Document Management where the user can save a
Word Document in a Blob Field, but the application was wrote in ( I'm
sorry ) Visual Basic.
    I thing it's done with OLE but I don't know "what Word Objects I need to
use" .
   I take a look in a Word Help about these OLE Objects, but I can't
understand how I can use them.
  If somebody can help  me, thanks a lot
   My private e-mail is abimael_olive...@hotmail.com

   Thanks by attention

   Abimael

 

Re:How I can save a WORD Document in a Blob Field


Quote
Abimael wrote:

> Hello friends

>      I see an application in Document Management where the user can save a
> Word Document in a Blob Field, but the application was wrote in ( I'm
> sorry ) Visual Basic.
>     I thing it's done with OLE but I don't know "what Word Objects I need to
> use" .
>    I take a look in a Word Help about these OLE Objects, but I can't
> understand how I can use them.
>   If somebody can help  me, thanks a lot
>    My private e-mail is abimael_olive...@hotmail.com

>    Thanks by attention

>    Abimael

This should work with a Paradox Table ...

Here is some code that might help you get started..

1) Choose a directory, Get the files ..., Save the Data

procedure TForm1.Process_RTF_Files;
var
 TempStrList : TStringList;
begin
 try
   { get the files in the directory }
  TempStrList := GetFileList('C:\RTF_Files\', '*.rtf');
   { assumes ID is the first field, and Text is the second}
   Load_RTF_Data( TempStrList,  Table1, 1, 0);
 finally
  TempStrList.Free;
 end;

end;

I would use a method like below to get the files from a directory;

function TForm1.GetFileList(const Path: string; const FileMask :
string): TStringList;
var
 I: Integer;
 SearchRec: TSearchRec;
begin
 try
  Result := TStringList.Create;
   try
    I := FindFirst(Path + FileMask, 0, SearchRec);
     while I = 0 do
      begin
        Result.Add(SearchRec.Name);
        I := FindNext(SearchRec);
      end;
  except

   raise;
  end;
 finally
  FindClose(SearchRec);
 end;
end;

  procedure TForm1.Load_RTF_Data( FileList : TStringList; aTable :
TTable;
   BlobFieldIndex, IDFieldIndex : Integer);
  var
    FS: TFileStream;    
    I : Integer;
  begin
    try
     for I := 0 to FileList.Count -1 do
      begin
       FS := TFileStream.Create(FileList[I], fmOpenRead);
        try
         if not (aTable.State in [dsInsert, dsEdit]) then aTable.Edit;
         TBlobField(aTable.Fields[BlobFieldIndex]).LoadFromStream(FS);
         aTable[IDFieldIndex ].AsString := FileList[I]; { save the File
path and name ID }
         aTable.Post;
        finally
         FS.Free;
        end; { try finally }
      end; { for loop }
    except

    end;{ try except }
  end;

HTH
--

                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer                       .
. TVisualBasic:=class(None)               .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) home (dot) com    .
-------------------------------------------

Other Threads