I have a word file that I want to output in two streams. The first is for conversion to XML but I need to maintain some partial tagging, thus I am saving as .rtf. The second stream is for future pdf creation and I need to clean the original file using a premade Word macro.
It is the second stream I am having trouble with. I can get the output of the first stream fine, I can save the second stream as a word file, but I can't get the macro to work and/or the changed content to save.
#Create filenames
$file =~ s/(.*)\.fin/$1/i;
$file = $1;
my $fileName = "$file.rtf";
my $fileName2 = "$file.doc";
#Convert to RTF
my $doc = Win32::OLE->new('Word.Application', 'Quit');
$doc->Documents->Open($path);
$doc->ActiveDocument->SaveAs({FileName => $fileName, FileFormat => wdF
+ormatRTF});
#Close Winword
$doc->Quit();
undef $doc;
#Run pretty print macro and save as word doc format
my $doc1 = Win32::OLE->new('Word.Application', 'Quit');
$doc1->Documents->Open($path);
$doc1->ActiveDocument->Run("psqtemplate");
$doc1->ActiveDocument->SaveAs({FileName => $fileName2});
# Close Winword
$doc1->Quit();
undef $doc1;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.