in reply to Re: Win32::OLE SaveAs Unicode
in thread Win32::OLE SaveAs Unicode

Sorry, I was too fast, changing to

$doc->SaveAs( { Filename => $filename_out, FileFormat => wdFormatText, Encoding => '1200', } );

does it better.

A note: I always use Word Macro Recorder and do my processing manually,

then I 'translate' the VBA code to perl code,

which is straight forward normally.

Replies are listed 'Best First'.
Re^3: Win32::OLE SaveAs Unicode
by Anonymous Monk on Jun 20, 2018 at 13:52 UTC

    Strange enough, if I save to a temporary file with

    my $filename_out = new File::Temp( UNLINK => 0, SUFFIX => '.txt' );

    I get the following error: Win32:OLE UsedRange error 0x80020005: "Type mismatch"

      File::Temp->new
      returns a file handle, not a file name.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

        The object stringifies to a filename, but maybe Win32::OLE doesn't stringify the object.

        Maybe manually stringifying helps:

        ... Filename => "$filename_out", ...
Re^3: Win32::OLE SaveAs Unicode
by Anonymous Monk on Jun 20, 2018 at 13:22 UTC

    It works (with the correction), thank you! I'll have a look at the idea of VBA!