Hello all, Here is what I seek: My Perl reads an input file with about 80 rows of data. For each row I need to create a new DOCX with some of the data from that input row. All MS-WORD files go the same folder. I spent a couple of days trying to figure this out but couldn't. Please, could any of you provide me with a simple example of a very simple Perl pgm that automatically creates 2 docx files, enters in them a constant and a variable from the input file, and saves them, without the user's intervention. I can't save the docx files. I get error: "Can't call method "SaveAs" on an undefined value at DOC.pl line 18, <INPUTFILE> line 1."
use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $path = 'E:/MASAV/DOC/'; my $input = 'input.txt'; my $in_file = $path . $input; my $counter = 4534; my $My_Word = Win32::OLE->new('Word.Application') or die "Problem with MS-WORD"; open (INPUTFILE, "<$in_file")|| die "Can not open $in_file\n"; while(<INPUTFILE>) { chomp $_; $counter++; my $docx_name = $counter.".docx"; $My_Word->{'Visible'} = 0; $My_Word->{DisplayAlerts} = 0; my $My_Save = $My_Word->ActiveDocument->SaveAs( {FileName => $docx_name, FileFormat => wdFormatDocument}); $My_Word->{ActiveDocument}->Close; } $My_Word->Quit;
In reply to create .docx files (MS-WORD with WIN32::OLE) by gadi99
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |