JNM
JNM

Reputation: 125

Using "msoEncodingUTF8" with Win32::OLE in a perl script

I'm having a Perl script which saves a Word document as a HTML one. The following code works:

use strict;
use Win32::OLE::Const 'Microsoft Word';
[...]
$go_word_doc->SaveAs2({
    FileName => $gs_html_name,
    FileFormat => wdFormatFilteredHTML
    });

In order to encode the output file in UTF-8, I turned my command in this way:

$go_word_doc->SaveAs2({
    FileName => $gs_html_name,
    FileFormat => wdFormatFilteredHTML,
    Encoding => msoEncodingUTF8
    });

The problem is that "msoEncodingUTF8" is seen as a bareword, and I can't find anywhere what I'm supposed to add for it to work.

Could anyone help, please? Thanks in advance.

Upvotes: 0

Views: 282

Answers (2)

JNM
JNM

Reputation: 125

The following command will create msoEncodingUTF8 (and other constants) for you:

use Win32::OLE::Const 'Microsoft Office [0-9.]+ Object Library';

Upvotes: 1

ikegami
ikegami

Reputation: 385655

The MsoEncoding Enum gives names to the Windows code pages. msoEncodingUTF8 is the name given to the UTF-8 code page, 65001.

use constant msoEncodingUTF8 => 65001;

Upvotes: 1

Related Questions