#!/bin/perl

    use Win32::OLE;
    use Win32;

    my ($Word, $tmp_out_file);

    $tmp_out_file = Win32::GetCwd() . "__some_junk_temp_file__.txt";
    open(TMP_OUT_FILE, '>', $tmp_out_file) or 
        die "$0: error opening temporary output file \"$tmp_out_file\": $!";
    print TMP_OUT_FILE "one line of text\n";
    close TMP_OUT_FILE;

    if (! ($Word = Win32::OLE->new('Word.Application')))
    {
        die "failed to start MS Word, aborting\n"; 
    }
    $Word->{Visible} = 1;     # make word visible
    $Word->Activate;          # and activate word
    $Word->Documents->Add;    # create a new, empty document
    $Word->Selection->InsertFile($tmp_out_file);
    $Word->ActiveDocument->PageSetup->{LeftMargin}  = 36;   # 0.5 in
    $Word->ActiveDocument->PageSetup->{RightMargin} = 36;   # 0.5 in

    # mark newly created document as "saved" (so it can be clicked away
    # without a prompt to save the "file").
    $Word->ActiveDocument->{Saved} = 1;
    unlink $tmp_out_file;
