Kbase P102309: How to open a text file in MS Word using a specific encoding
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Unverified
GOAL:
How to open a text file in MS Word using a specific codepage encoding
FIX:
A text file doesn't contain any encoding information. So when is opened in MS Word, the right encoding should be specified.
Below is an example of how to open it using the ISO8859-1 codepage (msoEncodingISO88591Latin1).
The filename in this case is: "C:\aaa.txt" and should exist.
/*---------------------------*/
DEFINE VARIABLE chWordApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chDoc AS COM-HANDLE NO-UNDO.
CREATE "Word.application" chWordApplication.
chWordApplication:VISIBLE=TRUE.
chWordApplication:Documents:OPEN("C:\aaa.txt", ).
chDoc = chWordApplication:Documents:Open (
"C:\aaa.txt",
no, /*<anytype>-ConfirmConversions BY-VARIANT-POINTER*/
no, /*<anytype>-ReadOnly BY-VARIANT-POINTER */
yes, /*<anytype>-AddToRecentFiles BY-VARIANT-POINTER,*/
"", /*<anytype>-PasswordDocument BY-VARIANT-POINTER,*/
"", /*<anytype>-PasswordTemplate BY-VARIANT-POINTER,*/
no, /*<anytype>-Revert BY-VARIANT-POINTER,*/
"", /*<anytype>-WritePasswordDocument BY-VARIANT-POINTER,*/
"", /*<anytype>-WritePasswordTemplate BY-VARIANT-POINTER,*/
"wdOpenFormatEncodedText", /*<anytype>-Format BY-VARIANT-POINTER,*/
"msoEncodingISO88591Latin1", /*<anytype>-Encoding BY-VARIANT-POINTER,*/
yes, /*<anytype>-Visible BY-VARIANT-POINTER,*/
no, /*<anytype>-OpenAndRepair BY-VARIANT-POINTER,*/
0, /*<anytype>-DocumentDirection BY-VARIANT-POINTER,*/
YES, /*<anytype>-NoEncodingDialog BY-VARIANT-POINTER,*/
).
chWordApplication:visible = yes.
RELEASE OBJECT chWordApplication.
/*---------------------------*/