如何编辑在VBA中以读取模式打开的Word文档 [英] How to edit a Word document that opens in read-mode in VBA

查看:404
本文介绍了如何编辑在VBA中以读取模式打开的Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编辑使用VBA从客户那里获得的Word文档,而客户通常以无法编辑的视图"将它们提供给我.因此,我想在执行任务之前在宏中启用编辑".

I am editing Word documents I get from clients with VBA, and the clients often give them to me in an 'uneditable view'. Thus, I would like to 'enable editing' in within my macro before doing my tasks.

请注意,我并不是说该文档处于只读"状态,因为我认为它不是(手动打开文档时,在文档标题栏中看不到[read only]文本).我还尝试按照这篇文章,但对文档的打开方式没有影响.手动打开文档时,我看到的是一个"2-页面视图",两侧带有箭头以向前/向后翻页,当我尝试编辑文档时,我在左下角看到一条状态消息文档的框架:This modification is not allowed because this document is opened for viewing only.我可以通过转到View > Edit Document手动将文档设置为可编辑状态.

Note that I did not say the document is in 'read-only' as I do not think it is (I do not see the [read only] text in the document title bar when I open it manually). I have also tried setting readOnly=false as described in this post, but it did not make a difference to how the document opened. what I am seeing when I open the document manually is a '2-page view' with arrows on the sides to page forward/back, and when I try to edit the document I see a status message in the lower-left corner of the document's frame: This modification is not allowed because this document is opened for viewing only. I can manually make the document editable by going to View > Edit Document.

推荐答案

我花了一段时间搜索这个,因为我不知道该视图被称为读取模式",因此我认为值得分享.我的策略是在打开此行的文档后切换为读取模式": ActiveDocument.ActiveWindow.View.ReadingLayout = False

I spent a while searching for this one as I didn't know the view was called 'read-mode', so I thought it was worth sharing. My strategy was to 'toggle off read-mode' once I opened my document with this line: ActiveDocument.ActiveWindow.View.ReadingLayout = False

REF: https://msdn.microsoft.com/zh-CN/vba/word-vba/articles/view-readinglayout-property-word

这篇关于如何编辑在VBA中以读取模式打开的Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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