Any advice / comments would be greatly appreciated...
Background: I am writing a Win32::Gui application that stores contacts in flat text files and can then regroup certain ones to make a mail merge letter, amongst other things. I know that there are various other applications around to do a similar sort of thing, but Ichose to do this as there was a request for something similar at work and to take the opportunity to learn some perl. As is probably the case with most of you I find it much easier to learn when doing...
Anyway, when coming to generate the Word mailmerge documnet - actually I am using an existing file and saving it with another name / location after changing the datasource. All of this works fine with the below code
my $datasource="somelocation\\somefile.cdm";
my $savelocation="somelocation\\somefile.doc";
use strict;
use Win32::OLE ;
use Win32::OLE::Const 'Microsoft Word';
my $Word= Win32::OLE->new('Word.Application', 'Quit');
$Word->Documents->Open($template);
$Word->ActiveDocument->MailMerge->OpenDataSource($datasource,);
$Word->ActiveDocument->SaveAs($savelocation);
Note: I used *.cdm as the extension as it was recomended to use something that word did not recognise so that it would not automatically assume the field and recorde delimiters.
When I do this word brings up a dialog box asking me to select the delimters. "|" for field and "~" for record.
Does anyone know how I can tell word what these are and thus avoid this intrusive dialog box?
Look forward to hearring your wisdom.
Cheers,
Gerard.
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.