"ScreenUpdating = False" 不适用于 Headers/Footers
"ScreenUpdating = False" Not Working for Headers/Footers
我正在使用 VSTO(在 VB 中)构建一个 Word 加载项,但我遇到了一个非常烦人的问题。我想在删除文档每个文章中的所有内容控件时关闭 ScreenUpdating。所以我做了以下事情:
Application.ScreenUpdating = False
'loop through all open documents
For Each thisDoc As Word.Document In gbl_docList
'loop through all stories in each doc
For Each thisStoryRange As Word.Range In thisDoc.StoryRanges
thisDoc.Activate() 'active this doc so we can work on it
thisStoryRange.Select() 'select the range
'remove all Content Controls
For Each thisCC As Microsoft.Office.Interop.Word.ContentControl In thisStoryRange.ContentControls
thisCC.Delete() 'remove this CC
Next 'next CC
Next 'next story
Next 'next doc
Application.ScreenUpdating = True
但是,每当 Word 循环浏览页眉或页脚文章时,它会开始在屏幕底部打开一个面板并将其显示给用户,这会导致尴尬的闪烁。如果没有 Headers/Footers,一切正常。
问题:
有人遇到过这个问题吗?有什么建议么?
作为替代解决方案,是否有任何方法可以在 Word 中 minimize/hide Word 文档,但保持 Word window 打开?我只能找到 minimize/hide 整个 Word 的方法。
我可以确认,尤其是在更高版本的 Office 中,ScreenUpdating 设置无法以多种方式工作(您会注意到功能区控件不断更新,例如根据您在程序中选择的文本从粗体更新为普通,或者就像你在处理 Headers/Footers)
时所做的那样
我早在 2014 年就以这种方式报告过,它已提供给 Office 团队,但(据我所知)从未得到解决。我的存档中还有邮件和复制品,甚至还有一段视频。重现基于此演示代码:
https://msdn.microsoft.com/en-us/library/office/ff197438(v=office.15).aspx
唯一的选择是在处理之前最小化 MS Word 并在完成后恢复其大小,或者使 MS Word 完全不可见(如果这是一项耗时的功能,您可以在处理有一些进展时显示一个对话框)并恢复完成后的可见性。
我正在使用 VSTO(在 VB 中)构建一个 Word 加载项,但我遇到了一个非常烦人的问题。我想在删除文档每个文章中的所有内容控件时关闭 ScreenUpdating。所以我做了以下事情:
Application.ScreenUpdating = False
'loop through all open documents
For Each thisDoc As Word.Document In gbl_docList
'loop through all stories in each doc
For Each thisStoryRange As Word.Range In thisDoc.StoryRanges
thisDoc.Activate() 'active this doc so we can work on it
thisStoryRange.Select() 'select the range
'remove all Content Controls
For Each thisCC As Microsoft.Office.Interop.Word.ContentControl In thisStoryRange.ContentControls
thisCC.Delete() 'remove this CC
Next 'next CC
Next 'next story
Next 'next doc
Application.ScreenUpdating = True
但是,每当 Word 循环浏览页眉或页脚文章时,它会开始在屏幕底部打开一个面板并将其显示给用户,这会导致尴尬的闪烁。如果没有 Headers/Footers,一切正常。
问题:
有人遇到过这个问题吗?有什么建议么?
作为替代解决方案,是否有任何方法可以在 Word 中 minimize/hide Word 文档,但保持 Word window 打开?我只能找到 minimize/hide 整个 Word 的方法。
我可以确认,尤其是在更高版本的 Office 中,ScreenUpdating 设置无法以多种方式工作(您会注意到功能区控件不断更新,例如根据您在程序中选择的文本从粗体更新为普通,或者就像你在处理 Headers/Footers)
时所做的那样我早在 2014 年就以这种方式报告过,它已提供给 Office 团队,但(据我所知)从未得到解决。我的存档中还有邮件和复制品,甚至还有一段视频。重现基于此演示代码:
https://msdn.microsoft.com/en-us/library/office/ff197438(v=office.15).aspx
唯一的选择是在处理之前最小化 MS Word 并在完成后恢复其大小,或者使 MS Word 完全不可见(如果这是一项耗时的功能,您可以在处理有一些进展时显示一个对话框)并恢复完成后的可见性。