* Convert .TXT to .DOC format >>>>>FUNCTION ConvertDoc >>>>>LPARAMETERS lcTxtFile >>>>> >>>>>#include "wdconst.h" >>>>>#DEFINE wdAutoInchesToPoints 72 >>>>> >>>>>LOCAL oWord as "word.application" >>>>>oWord = CREATEOBJECT('Word.Application') >>>>> >>>>>lcFileDoc = LEFT(lcTxtFile,ATC('.txt',lcTxtFile)-1)+'.doc' >>>>>IF FILE(lcFileDoc) >>>>> ERASE (lcFileDoc) >>>>>ENDIF >>>>>IF file(lcTxtFile) >>>>> * open text file >>>>> oWord.WordBasic.FileOpen(lcTxtFile) >>>>> oWord.Selection.TypeParagraph >>>>> oWord.ActiveDocument.Select >>>>> WITH oWord.Selection >>>>> .Range.ListFormat.RemoveNumbers >>>>> .Font.Name = "Courier New" >>>>> .Font.Size = 8 >>>>> ENDWITH >>>>> WITH oWord.ActiveDocument.PageSetup >>>>> .LineNumbering.Active = .F. >>>>> .Orientation = 1 >>>>> .BottomMargin = .3 * wdAutoInchesToPoints >>>>> .TopMargin = .25 * wdAutoInchesToPoints >>>>> .LeftMargin = 1.0 * wdAutoInchesToPoints >>>>> .RightMargin = 1.0 * wdAutoInchesToPoints >>>>> ENDWITH >>>>> * save document into the doc file in the Word format with password >>>>> With oWord.ActiveDocument >>>>> .Protect(wdAllowOnlyReading,.F.,"xyz123xyz") >>>>> .RemovePersonalInformation = .F. >>>>> .RemoveDateAndTime = .F. >>>>> .SaveAs(lcFileDoc,0) >>>>> EndWith >>>>> oWord.WordBasic.FileClose() >>>>>ENDIF >>>>>oWord.Quit >>>>>RETURN>>>>>I've experienced "This file is in use by another application or user. (C:\Documents and Settings\...\normal.dot)" Then it doesn't properly close the application.