Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Application open in user's PC, how to...
Message
 
To
12/09/2006 15:08:56
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01152901
Message ID:
01153158
Views:
13
This is how I got it going:
* The goal here is to create a .DOC from a .TXT output and
* yet retain the .TXT on the server to be archived (we don't
* want to literally convert the original file).
* Convert .TXT to .DOC format
LPARAMETERS lcTxtFile
IF !FILE(lcTxtFile) && open text file
   RETURN
ENDIF
#DEFINE wdAutoInchesToPoints 72
#DEFINE wdAllowOnlyReading 3
#DEFINE wdFormatDocument 0
LOCAL oWord AS "word.application"
oWord = CREATEOBJECT('Word.Application')
lcFileDoc = FORCEEXT(lcTxtFile, 'doc') &&LEFT(lcTxtFile,ATC('.txt',lcTxtFile)-1)+'.doc'
IF FILE(lcFileDoc)
   ERASE (lcFileDoc)
ENDIF
WITH oWord
   .WordBasic.FileOpen(lcTxtFile)
   .SELECTION.TypeParagraph
   .ActiveDocument.SELECT
   WITH .SELECTION
      .RANGE.ListFormat.RemoveNumbers
      .FONT.NAME = "Courier New"
      .FONT.SIZE = 8
   ENDWITH
   WITH .ActiveDocument
      .PageSetup.LineNumbering.ACTIVE = .F.
      .PageSetup.ORIENTATION = 1
      .PageSetup.BottomMargin = .3 * wdAutoInchesToPoints
      .PageSetup.TopMargin = .25 * wdAutoInchesToPoints
      .PageSetup.LeftMargin = 1.0 * wdAutoInchesToPoints
      .PageSetup.RightMargin = 1.0 * wdAutoInchesToPoints
      .PASSWORD="test"   && save document into the doc file in the Word format with password
      .PROTECT(1)
      .RemovePersonalInformation = .F.
      .SAVEAS(lcFileDoc, wdFormatDocument)
   ENDWITH
   .WordBasic.FileClose()
   .QUIT
ENDWITH
Just dinkering with it, really . . .
Previous
Reply
Map
View

Click here to load this message in the networking platform