in reply to Word wdDocumentsPath and ActivePrinter
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
|
|---|