RE: Save As option in Win32::OLE
"Jan Dubois" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <008d01c9ef1e$64840200$2d8c0600$@com> |
Sorry, I'm too tired to play with this right now. Did you try out the other wdFormatXxx values (e.g. just wdFormatText) to see if one of them is doing what you want? If that still doesn't help, then I would suggest looking at the FileConverters collection of the Application object. Search for the "Plain Text" converter and then use the SafeFormat property of that converter as the FileFormat argument to SaveAs. This is probably what really happens when you do the manual SaveAs. Maybe the "Plain Text" converter doesn't use one of the predefined formats. Cheers, -Jan PS: I think your question is off-topic on the perl-xml mailing list. I would recommend to move any further discussion of this subject to perl-win32-users instead. > -----Original Message----- > From: Ramkumar [mailto:[email protected]] > Sent: Wednesday, June 17, 2009 12:26 AM > To: 'Jan Dubois' > Cc: [email protected] > Subject: RE: Save As option in Win32::OLE > > 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