【问题标题】:Perl Supress Saveas Dialog using Word OLEPerl 使用 Word OLE 抑制 Saveas 对话框
【发布时间】:2013-10-28 14:30:27
【问题描述】:

我有一个正在运行的 perl 脚本,它使用 Microsoft Word OLE 并针对我传递给它的内容运行拼写检查。我遇到了一个问题,因为我没有保存文件或文档,所以当我尝试退出 word 时,它希望我保存一些东西(提示另存为)。

我需要能够隐藏此消息或欺骗文档使其认为它已被保存。这是可能的吗?或者您能想到其他解决方案吗?

我尝试了 DisplayAlerts = 0,但似乎也没有帮助。

sub LaunchSpellcheck
{
#Check the version to see if there are updates.
checkVersion();

#Open up MS Word and only display the spellcheck box.
my $Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application');
my @windows = FindWindowLike(undef,"Microsoft Word","");
SetActiveWindow(@windows[0]);
$Word->{'Visible'} = 0;

#Add a new document in word
my $TmpDocument = $Word->Documents->Add();
$TmpDocument = $TmpDocument->{Content};
#Add contents of clipboard to document
$TmpDocument ->{Text} = $clipboard->GetText();

#Check the spelling
$Word->ActiveDocument->CheckSpelling;
#Set the content of the file back to the clipboard.
$clipboard->Set($TmpDocument ->{Text});

#Hide save as dialog
$Word->{'DisplayAlerts'} = 0;
$Word->Quit;

MessageBox('The spellchecked content has been saved to your clipboard.','Spellcheck Complete');

#Log that the tool was used to the global log.
TrackUsage();
}

【问题讨论】:

    标签: perl dialog ole


    【解决方案1】:

    这对我有用:

    my $Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application');
    $Word->{'DisplayAlerts'} = 0;
    ....
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-01
      • 2013-12-01
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      • 2011-05-10
      • 2012-10-21
      • 1970-01-01
      相关资源
      最近更新 更多