nevinl has asked for the wisdom of the Perl Monks concerning the following question:
Saved macro when recording within Word:$word = CreateObject Win32::OLE 'Word.Application' or die $!; $word->{DisplayAlerts} = 0; if (${$env_ref}{DEBUG_AUDIT_REPORT_VISIBLE}) { $word->{'Visible'} = 1; } $document = $word->Documents->Add; ## Change the default save location: ##$word->Options->DefaultFilePath(wdDocumentsPath); my ($path_current); my ($path_default) = '\\\\trhmc-fs04\\users04\\u02904'; my ($path_new) = 'C:\\Documents'; ## Outputs: Default save path: (\\trhmc-fs04\users04\u02904) print "Default save path: (". $word->Options->DefaultFilePath(wdDocume +ntsPath) . ")\n"; ## Outputs: Default save path: (\\trhmc-fs04\users04\u02904) $path_current = $word->Options->DefaultFilePath(wdDocumentsPath); print "Default save path: (". $path_default . ")\n"; ## Re-assign the default path: ## Outputs: Can't modify non-lvalue subroutine call at report_db_devel +opment.pl line 1983. #$word->Options->DefaultFilePath(wdDocumentsPath) = $path_new; #print "New save path: (". $word->Options->DefaultFilePath(wdDocuments +Path) . ")\n"; ## Re-assign the default path to the SAME thing ## Outputs: Can't modify non-lvalue subroutine call at report_db_devel +opment.pl line 1994. #$word->Options->DefaultFilePath(wdDocumentsPath) = $path_default; #print "New save path: (". $word->Options->DefaultFilePath(wdDocuments +Path) . ")\n"; ## Outputs: Default new path: (\\trhmc-fs04\users04\u02904) $word->Options->DefaultFilePath( { 'wdDocumentsPath' => $path_new, }); print "New save path: (". $word->Options->DefaultFilePath(wdDocumentsP +ath) . ")\n"; ## Outputs: Default new path: (\\trhmc-fs04\users04\u02904) $word->Options->DefaultFilePath( { 'Path' => $path_new, }); print "New save path: (". $word->Options->DefaultFilePath(wdDocumentsP +ath) . ")\n"; ## Outputs: Use of unitilized value in print at report_db_development. +pl line 2014. print $word->Options->DefaultFilePath; ## Outputs: Use of unitilized value in print at report_db_development. +pl line 2018. print $word->Options->{'DefaultFilePath'}; ## Outputs: Use of unitilized value in print at report_db_development. +pl line 2021. print $word->Options->DefaultFilePath(); ## Outputs: \\trhmc-fs04\users04\u02904 print $word->Options->DefaultFilePath(wdDocumentsPath); ## Outputs: Default save path: (\\trhmc-fs04\users04\u02904) $path_new = $word->Options->DefaultFilePath(wdDocumentsPath); print "Default save path: (". $word->Options->DefaultFilePath(wdDocume +ntsPath) . ")\n"; foreach $path_new ( 'C:\Documents', 'C:\\Documents', 'C:\Documents\\', 'C:\\Documents\\', "C:\\Documents", "C:\\Documents\\", ) { ## Cannot modify non-lvalue subroutine call at ... #$word->Options->DefaultFilePath(wdDocumentsPath) = $path_new; print "Default save path: (". $word->Options->DefaultFilePath(wdDo +cumentsPath) . ")\n"; $word->Options->DefaultFilePath( { 'Path' => $path_new, 'wdDocumentsPath' => $path_new, 'Path:=wdDocumentsPath' => $path_new, }); print "Default save path: (". $word->Options->DefaultFilePath(wdDo +cumentsPath) . ")\n"; } ## Outputs: \\TRHMC-IMGDIS1\ECRTJPLF on NE01: print $word->{ActivePrinter}; ## Outputs: \\TRHMC-IMGDIS1\ECRTJPLF on NE01: my ($default_printer) = $word->{ActivePrinter}; print $default_printer; ## Outputs: \\TRHMC-IMGDIS1\ECRTJPLF on NE01: $word->{ActivePrinter} = '\\trhmc-prt6\EDNLJP5L'; print "Default printer: $word->{ActivePrinter}\n";
and the result of the Object Browser within VB:Options.DefaultFilePath(Path:=wdDocumentsPath) = _ "\\trhmc-fs04\users04\U02904\audit_basic\cgi-bin\" ActivePrinter = "PDFill PDF Writer" ActivePrinter = "\\TRHMC-IMGDIS1\ECRTJPLF" ActivePrinter = "\\trhmc-prt6\EDNLJP5L"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Word wdDocumentsPath and ActivePrinter
by stiller (Friar) on Feb 09, 2008 at 09:43 UTC | |
by nevinl (Novice) on Feb 09, 2008 at 21:50 UTC | |
by stiller (Friar) on Feb 10, 2008 at 00:09 UTC | |
|
Re: Word wdDocumentsPath and ActivePrinter
by stiller (Friar) on Feb 10, 2008 at 11:55 UTC |