Selvakumar has asked for the wisdom of the Perl Monks concerning the following question:

I want to save as word file to xml file. but the xml file differs from manual save as XML file option from word. Can anybody suggest to do this?
use strict; use warnings; use Cwd; use Win32::OLE::Const 'Microsoft Word'; my $Word = Win32::OLE->new('Word.Application'); $Word->{'Visible'} = 1; $Word->{DisplayAlerts} = 0; my $folderpath=getcwd()."/"; opendir(RDIR,"$folderpath"); for my $xmlfile (readdir(RDIR)) { if ($xmlfile=~/\.doc$/) { $xmlfile=$folderpath.$xmlfile; my $xmlfile1=$xmlfile; $xmlfile1=~s/\.doc$/\.xml/; my $doc = $Word->Documents->Open("$xmlfile"); $Word->ActiveDocument->SaveAs({FileName=>"$xmlfile1"}); $Word->{ActiveDocument}->Close; $doc->Close; } } $Word->Close;

Replies are listed 'Best First'.
Re: Word file save as xml file
by Gangabass (Vicar) on Aug 13, 2009 at 09:52 UTC

    See this node to find how to get proper FileFormat.

Re: Word file save as xml file
by Anonymous Monk on Aug 13, 2009 at 08:12 UTC