Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word Application open in user's PC, how to...
Message
 
 
À
12/09/2006 16:01:07
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01152901
Message ID:
01153153
Vues:
32
>>>Can we see part of the code? When I open a second instance of word using createobject(), open a file (Documents.Open(), save it (ActiveDocument.SaveAs(), close it (ActiveDocument.Close(0), and then oWord.quit(), everything about my instance is gone. The other instance doesn't know anything has happened.
>>>
>>
>>The goal here is to create a .DOC from a .TXT output and retain the .TXT on the server to be archived (we don't want to literally convert the file).
>>
>>
* 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.
>
>Does it make a difference if at the end, you use "oWord.ActiveDocument.Close(0)" rather than using wordbasic syntax?

AFAIK we don't need Close at all.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform