use Win32::OLE; $Win32::OLE::Warn = 3; eval {$word = Win32::OLE->GetActiveObject('Word.Application')}; die "Word not installed" if $@; unless (defined $word) { $word = Win32::OLE->new('Word.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Word"; } $word->Activate; $word->{visible} = 1; $oldfile =~ m!^(.+?)/([^/]+)$!; my $dir = $1 . '/'; my $name = $2; $word->ChangeFileOpenDirectory($dir); my $doc = $word->Documents->Open("$name"); ...