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, "$oldDocPath"); print "Reset Default save path to: " . $word->Options->DefaultFilePath(wdDocumentsPath) . "\n";