如何从 Perl 中以只读方式打开 Word 文档?
Perl 中是否有任何方法可以让我以只读模式获取对象, 以避免文件被其他用户锁定时弹出的对话框?
$document = Win32::OLE->GetObject("$docFile")
or die "can't open $docFile";
Is there any method within Perl which would allow me to get the object in a read only mode,
so as to avoid the dialog that pops up if the file is locked by another user?
$document = Win32::OLE->GetObject("$docFile")
or die "can't open $docFile";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那是因为你做错了。
GetObject
仅以默认行为打开一个对象。您应该创建Word.Application
对象:然后使用带有命名参数
ReadOnly
的Documents
集合Open
方法。像这样:阅读 http://msdn.microsoft.com/en-us/ library/bb216319.aspx 了解
Documents.Open
的语法That's because you're doing it wrong.
GetObject
just opens an object with the default behavior. You should create theWord.Application
object:Then use the
Documents
collectionOpen
method with the named parameterReadOnly
. Like so:Read http://msdn.microsoft.com/en-us/library/bb216319.aspx for the syntax for
Documents.Open