in reply to Word wdDocumentsPath and ActivePrinter

$word->Options->DefaultFilePath(wdDocumentsPath)

is the syntax of a subroutine call, and

$word->Options->DefaultFilePath(wdDocumentsPath) = $path_default;

is an attempt to assign to a subroutine call. That is possible for specially prepared subroutines, like for example substr, but here the error message tells it is not ok.

I don't have Word here now, but I suspect that something like

$word->Options->{DefaultFilePath}->{wdDocumentsPath} = $path_default;

e.g. setting an option rather than calling a sub, will do what you want. hth

Replies are listed 'Best First'.
Re^2: Word wdDocumentsPath and ActivePrinter
by nevinl (Novice) on Feb 09, 2008 at 21:50 UTC
    $word->Options->{DefaultFilePath}->{wdDocumentsPath} = $path_default;


    same output...I don't know if I understand the data structure, but it seems as though it is adding a branch to the original hash...not modifying an existing element?

    for instance:
    $word->Options->DefaultFilePath->{wdDocumentsPath} = $path_new; ---> output: Can't use an undefined value as a HASH reference at ....


    I thought that perhaps it was since I could not have access to regedit, maybe I couldn't modify the registry...but I'm able to modify it within Microsoft Word->options->Save

    Not that it matters, but this I've been trying it as console window and within a web application...
      Well, it's not the same output, allthough the net result is the same.

      I'm not very familiar with office automation, but I wonder if you have winword running in this last instance?

      Do you:

      use strict; use warnings; use Win32::OLE; # brings in constants like wdDocumentsPath use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; # reports OLE errors my $word = Win32::OLE->GetActiveObject('Word.Application') or Win32::OLE->new('Word.Application', 'Quit'); print "word is not running\n" unless defined $word;

      It's a subtle change in syntax thats needed I guess, but I can't find anything on google or here now that answers your particular question.

      good luck!