如何调用documents.open,避免出现“正在使用文件"对话框? [英] How can I call documents.open and avoid the 'file in use' dialog?

查看:675
本文介绍了如何调用documents.open,避免出现“正在使用文件"对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些非常简单代码来打开Word文档,并将其保存为新格式并关闭文件.但是,如果文档处于锁定状态并出现正在使用的文件"对话框,则会遇到问题.

I am writing some very simple code to open a word document, save it in a new format and close document. However I run into problems if the document has been left in a locked state and get the 'File in Use' dialog.

现在,我很乐意自动选择选项1或3,但似乎找不到方法.理想情况下,我将完全禁止通过open方法上的参数显示它.我正在使用Delphi,但这并不重要.

Now I would be delighted to pick option 1 or 3 automatically, but can't seem to find a way. Ideally I would prevent it from showing at all via a parameter on the open method. I'm using Delp but that's not really relevant.

    Wordapp.documents.Open(InputFile);

推荐答案

在ReadOnly设置为true的情况下调用open似乎可以解决此问题.

Calling open with ReadOnly set to true seems to fix this issue.

    Readonly := true;
    Wordapp.documents.Open(FName, false, Readonly);  //3rd parameter is readonly

参考: http://msdn.microsoft.com/en -us/library/office/ff835182.aspx

这篇关于如何调用documents.open,避免出现“正在使用文件"对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆