How can I call documents.open and avoid the 'file in use' dialog?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 00:46:40

问题


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.

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 Delphi, but that's not really relevant.

    Wordapp.documents.Open(InputFile);

回答1:


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

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

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



来源:https://stackoverflow.com/questions/13894095/how-can-i-call-documents-open-and-avoid-the-file-in-use-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!