2011-07-27 8 views
1

Windows Server上で実行されるWinSSHDに対してsshを使用するWindows 2008 R2/perl 5.14.1 x64/Word 2010管理者アカウントへのリモートアクセス。このperlスクリプトは、(ローカル、管理者)コマンドラインから正常に動作:win32:WordへのOLE呼び出しは、SSHDを介してvisible = 0、リモートスクリプトでは動作しません。

C:\Users\Administrator>perl -w \winbat\ole_example.pl 
>> Creating a new document 
>> Creating a selection at insertion point 
>> Insert text >> Save document 
OLE exception from "Microsoft Word":Command failedWin32::OLE(0.1709) error 0x800a1066 
in METHOD/PROPERTYGET "SaveAs" at \winbat\ole_example.pl line 34 

任意のヒント:

use warnings; 
use strict; 
use Win32::OLE; 
use Win32::OLE::Const 'Microsoft.Word'; # wd constants 
use Win32::OLE::Const 'Microsoft Office 14.0 Object Library'; # mso constants 
use Win32::OLE qw(in with); 
my $word = CreateObject Win32::OLE 'Word.Application' or die $!; 
$word->{'Visible'} = 0; # note, for debugging only; otherwise use 0 
print ">> Creating a new document\n"; 
my $document = $word->Documents->Add; 
with( $document->{BuiltinDocumentProperties}, 
Title => "OLE Word Perl", 
Author => "Car Friedberg", 
Subject => "simple example"); 
print ">> Creating a selection at insertion point\n"; 
# selection is the insertion point. 
my $selection = $word->Selection; 

print ">> Insert text \n"; 
$selection->TypeText("This is a test."); 
$selection->TypeParagraph; 
$selection->TypeText("End of test."); 

print ">> Save document \n"; 
# save the document (works with Word 2010) (could use wdFormatPDF or wdFormatRTF) 
$word->ActiveDocument->SaveAs({ 
FileName => 'exampletext.doc', 
FileFormat => wdFormatDocument, 
LockComments => msoFalse, 
Password => "", 
AddToRecentFiles => msoFalse, 
    WritePassword => "", 
    ReadOnlyRecommended => msoFalse, 
    EmbedTrueTypeFonts => msoFalse, 
    SaveNativePictureFormat => msoFalse, 
    SaveFormsData => msoFalse, 
    SaveAsAOCELetter => msoFalse}); 

$word->ActiveDocument->Close(wdDoNotSaveChanges); 
$word->Quit();` 

リモートシェルの出力は次のようになりますか?私は、{visible} = 0という単語を使用することに問題があることを知ります。これは、リモートで実行するように設定する必要があります。私が見つけた1つの記事は、アプリケーションアプリケーションという言葉を作成するためにMicrosoft Officeの完全な機能を使用することを提案しましたが、これをwin32 :: OLEが受け入れるもの、例えば に翻訳する方法を理解できませんでした。Microsoft.Office.Interop.Word.ApplicationClass createobject ( "Word.Application") (私は特定の提案を見つけることができませんでしたが、それはperlishではありませんでした)。

任意の助けてくれてありがとうは

答えて

1

ワンポイントがFileName => 'exampletext.doc'である - これはおそらく、どこかにそれが許可されていないかどうか、十分なスペースを節約しようとしている...絶対パスではありません...

どの可能性
WinSSHDはサービスとして実行されていますか?
はいの場合、オフィスの自動化はMSによってサポートされていません - http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

関連する問題