RE: Save As option in Win32::OLE

"Ramkumar" <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Organization PMG
Message-ID <[email protected]>
Hi Jan,

Sorry. Small correct in my below mail: By perl code output coming without
breaks of each line like:

Only problem is line break not applying in output txt.

Regards,
Ramkumar,

-----Original Message-----
From: Ramkumar [mailto:[email protected]] 
Sent: Wednesday, June 17, 2009 12:35 PM
To: 'Jan Dubois'
Cc: '[email protected]'
Subject: RE: Save As option in Win32::OLE

Jan wrote:
> You need to show the complete code.  I would suspect that you are not
>including the Word constants using Win32::OLE::Const.  If you are
>using "strict" and "warnings" then you would have been told by Perl.

>But without seeing your complete source it is impossible to tell.

>You also didn't mention how the script output is different from
>the manual output.

Complete code:

	use Win32::OLE;
	use Win32::OLE::Const 'Microsoft Word';

	my $folderpath=$ARGV[0];

	my $Word = Win32::OLE->new('Word.Application');
	$Word->{'Visible'} = 0;
	$Word->{DisplayAlerts} = 0;
	my $doc = $Word->Documents->Open("$folderpath\\Chapter 1.doc");
	$Word->ActiveDocument->SaveAs({FileName=>"$folderpath\\Chapter
1.txt", FileFormat=>wdFormatTextLineBreaks});
	$Word->{ActiveDocument}->Close;
	$doc->Close;
	$Word->Close;

By manual (In word application) output coming with breaks in each line like:

    Writing, of whatever type, can be a draining and dreaded task.   But it
can also be a passion, 
an adventure, and even a compulsion that occasionally brings great
satisfaction as a payoff to 
the pain.   One group of people write simply because it is demanded of them
by employers (or 
teachers).  A second group set down words because they like to write.  And a
special third 
group may internally be compelled to pen things due to changes in the brain
that Alice Flaherty 
and colleague neurologists label hypergraphia, ?an overpowering desire to
write.? [1]  

By perl code output coming with breaks each line like:

    Writing, of whatever type, can be a draining and dreaded task.   But it
can also be a passion, an adventure, and even a compulsion that occasionally
brings great satisfaction as a payoff to the pain.   One group of people
write simply because it is demanded of them by employers (or teachers).  A
second group set down words because they like to write.  And a special third
group may internally be compelled to pen things due to changes in the brain
that Alice Flaherty and colleague neurologists label hypergraphia, "an
overpowering desire to write." [1]  

Single line without line break

I am using perl5.8.8. basic console perl programming. Please suggest.

Regards,
Ramkumar,


-----Original Message-----
From: Jan Dubois [mailto:[email protected]] 
Sent: Wednesday, June 17, 2009 12:18 PM
To: [email protected]; [email protected]
Subject: RE: Save As option in Win32::OLE

On Tue, 16 Jun 2009, Ramkumar wrote:
> 
> I am opening word document through Win32::OLE and saving as Plain Text
with
> Encoding option MS-DOS and Insert-Line-Break option.
> 
> I achieved the above output through perl, but output not matching with the
> output which is done the same manual operation in MS-word.
> 
> My code:
> 	my $Word = Win32::OLE->new('Word.Application');
> 	$Word->{'Visible'} = 0;
> 	$Word->{DisplayAlerts} = 0;
> 	my $doc = $Word->Documents->Open("$folderpath\\Chapter 1.doc");
> 	$Word->ActiveDocument->SaveAs({FileName=>"$folderpath\\Chapter
> 1.txt", FileFormat=>wdFormatDOSTextLineBreaks});
> 	$Word->{ActiveDocument}->Close;
> 	$doc->Close;
> 	$Word->Close;
> 
> Please correct me if I did any mistake on the above code.




_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.