phew, I got my windows computer here now, and a solution.

The syntax to set the path is

$word->Options->SetProperty("DefaultFilePath", wdDocumentsPath, 'C:\\stiller');

Turns out this change is permanent, so you might want to save the original path first, then setting it, before eventually resetting it to what it was before your script started:

use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; # report OLE runtime errors my $word = (Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit')); print "word is not running \n" unless defined $word; $word->{DisplayAlerts} = 0; # keep the old default so we can reset later my $oldDocPath = $word->Options->DefaultFilePath(wdDocumentsPath); print "Default save path was: $oldDocPath \n"; my $newPath; my $wantedPath = "C:\\stiller"; if (-e $wantedPath){ $newPath = $word->Options->SetProperty("DefaultFilePath" , wdDocumentsPath, $wantedPath); } else { print "Wanted path $wantedPath does not exist \n"; exit; } print "Default save path now: " . $word->Options->DefaultFilePath(wdDocumentsPath) . "\n"; $word->Options->SetProperty("DefaultFilePath", wdDocumentsPath, "$oldD +ocPath"); print "Reset Default save path to: " . $word->Options->DefaultFilePath(wdDocumentsPath) . "\n";

outputs:

Default save path was: h:\ Default save path now: c:\stiller\ Reset Default save path to: h:\

cheers


In reply to Re: Word wdDocumentsPath and ActivePrinter by stiller
in thread Word wdDocumentsPath and ActivePrinter by nevinl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.