Word2013中的CommandBar弹出行为 [英] CommandBar popup behaviour in Word2013
问题描述
我一直在注意其他论坛中关于MS决定从右键单击拼写上下文菜单中删除自动更正功能的一些帖子。 我个人认为我没有注意到它,但有兴趣看看是否可以放回来。
过去MS时我注意到了从UI中删除了一个有用的或无用的功能,底层工具仍然可用,所以我想我可以通过将CommandBarPopup ID 30066添加回拼写
命令栏来自定义拼写上下文右键菜单。  ;我能够毫无问题地做到这一点,但奇怪的是内置弹出窗口的行为与其他Word版本中的内置弹出窗口不同。 它就在那里,但它没有内容。 它不会复制拼写菜单顶部的建议更正列表
列表,也不包含内置的自动更正选项命令。 它只是一个强大的弹出窗口:-(
$
不要气馁,我坚持并且我已经管理了一个将在早期版本中复制过程的过程Word,但是开销可能会使它变得无用。我唯一想到的就是在自动更正弹出窗口中手动添加
建议拼写列表并手动添加自动更正选项按钮然后我创建了一个宏来复制(尽我所能)Word的弹出窗口创建自动更正条目的原生过程。令人讨厌的部分是
拼写命令栏必须重置并重新创建每个选择更改。 这是开销的成本,使整个事情成为可疑。您可以下载包含代码的模板:
http://gregmaxey.mvps.org/word_tip_pages/customize_shortcut_menu.html
$
我意识到我很多代码,但是如果有人看到它并且可以看到我已经完成的某些东西阻止了内置的自动更正弹出窗口的工作状态,那么它应该可能只是一个有用的工具。 谢谢。
I've been noticing a few posts in other forums regarding MS decision to remove the AutoCorrect feature from the right click spelling context menu. Personally I don't think I've ever noticed it, but was interested in seeing if it could be put back.
I've noticed in the past when MS removes a useful or (useless feature) from the UI, the underlying tool is still available so I thought I could just customize the spelling context right click menu by adding the CommandBarPopup ID 30066 back to the spelling
command bar. I was able to do that with no problem, but oddly the built-in popup does not behave like the built-in popup in other Word versions. It is there, but it has no content. It doesn't duplicate the list of suggested corrections list
at the top of the spelling menu and it doesn't contain the built-in AutoCorrect options command buton. It is just an empy popup :-(
Not to be discouraged, I pressed on and I've managed cobble together a process that will replicate the process in earlier versons of Word, but at a cost in overhead that will likely make it useless. The only thing I could think to do was to manually add
the list of suggested spellings in the AutoCorrect popup and manually add the AutoCorrect options button. I then created a macro to replicate (as best I could) Word's native process for creating autocorrect entries from the popup. The nasty part is that
the spelling command bar has to be reset and recreated with each selection change. That is the cost in overhead that makes the whole thing questionable. You can download a template containing the code:
http://gregmaxey.mvps.org/word_tip_pages/customize_shortcut_menu.html
I realize it is a lot of code, but if anyone looks at it and can see something I've done that prevents the built-in AutoCorrect popup from working like it seems it should then this might but a useful tool. Thanks.
标准代码:
Option Explicit
Public p_ThisApp As clsThisApp
Sub AutoExec()
InitiateAppClass
End Sub
Sub AutoOpen()
InitiateAppClass
End Sub
'Call this pocedure to initialize the clase
Public Sub InitiateAppClass()
Set p_ThisApp = Nothing
Set p_ThisApp = New clsThisApp
lbl_Exit:
Exit Sub
End Sub
Sub BuildControls()
Dim oPopUp As CommandBarPopup
Dim oCtr As CommandBarControl
Dim oBtn As CommandBarButton
Dim lngIndex As Long
Dim lngMarker As Long
CustomizationContext = ThisDocument.AttachedTemplate
'Prevent double customization
Set oPopUp = CommandBars.FindControl(Tag:="BuiltInAC")
If Not oPopUp Is Nothing Then GoTo lbl_Exit
On Error GoTo lbl_Exit
'Determine where the "Ignore All" control is located. This tells us how many suggested spellings are in the context menu.
lngMarker = CommandBars("Spelling").Controls("&Ignore All").Index
'Add the built-in AutoCorrect popup
Set oPopUp = CommandBars("Spelling").Controls.Add(msoControlPopup, 30096, , CommandBars("Spelling").Controls("&Hyperlink...").Index, 1)
With oPopUp
.Tag = "BuiltInAC"
.BeginGroup = True
End With
'I would have thought that the built-in popup would include the suggested spelling and the AutoCorrect options dialo, but it doesn't.
'Yuck. This means that they will have to be fudged and added\removed with each selection change :-(
For lngIndex = 1 To lngMarker - 1
Set oBtn = oPopUp.Controls.Add(msoControlButton, CommandBars("Spelling").Controls(lngIndex).ID)
With oBtn
.Caption = CommandBars("Spelling").Controls(lngIndex).Caption
.Style = msoButtonCaption
.Tag = CommandBars("Spelling").Controls(lngIndex).Caption
.OnAction = "CreateAutoCorrect"
End With
Next lngIndex
'Add the built-in AutoCorrect Options dialog
Set oBtn = oPopUp.Controls.Add(msoControlButton, 793)
ThisDocument.Saved = True
lbl_Exit:
Set oPopUp = Nothing
Set oBtn = Nothing
Exit Sub
End Sub
Sub RemoveContentMenuItem()
CustomizationContext = ThisDocument.AttachedTemplate
CommandBars("Spelling").Reset
ThisDocument.Saved = True
lbl_Exit:
Exit Sub
End Sub
Sub CreateAutoCorrect(Optional strWord As String)
Dim cmdBCtl As CommandBarControl
Dim oRng As Word.Range
Dim arrChars() As String
Dim lngLen As Long, lngIndex As Long
Dim strAppend As String
Set cmdBCtl = Application.CommandBars.ActionControl
Set oRng = Selection.Words(1)
lngLen = Len(oRng)
If lngLen <> Len(Trim(oRng)) Then
ReDim arrChars(lngLen - Len(Trim(oRng)) - 1)
For lngIndex = 0 To UBound(arrChars)
arrChars(lngIndex) = Mid(oRng, Len(Trim(oRng)) + lngIndex + 1, 1)
Next
End If
Application.AutoCorrect.Entries.Add Name:=Trim(oRng), Value:=cmdBCtl.Tag
For lngIndex = 0 To UBound(arrChars)
strAppend = strAppend & arrChars(lngIndex)
Next lngIndex
Selection.Words(1) = cmdBCtl.Tag & strAppend
RemoveContentMenuItem
lbl_Exit:
Exit Sub
End Sub
Class
Option Explicit
Private WithEvents m_oThisApp As Application
Private Sub Class_Initialize()
Set m_oThisApp = Word.Application
cls_Initialize_Reset
lbl_Exit:
Exit Sub
End Sub
Private Sub m_oThisApp_DocumentOpen(ByVal doc As Document)
cls_Initialize_Reset
lblbl_Exit:
Exit Sub
End Sub
Private Sub m_oThisApp_DocumentChange()
cls_Initialize_Reset
lbl_Exit:
Exit Sub
End Sub
Private Sub m_oThisApp_WindowSelectionChange(ByVal Sel As Selection)
cls_Initialize_Reset
lbl_Exit:
Exit Sub
End Sub
Private Sub cls_Initialize_Reset()
Dim lngCur As Long
On Error GoTo lbl_Exit
lngCur = System.Cursor
System.Cursor = wdCursorNormal
Module1.RemoveContentMenuItem
Module1.BuildControls
On Error GoTo 0
System.Cursor = lngCur
lbl_Exit:
Exit Sub
End Sub
Greg Maxey请访问我的网站:http://gregmaxey.mvps .org / word_tips.htm
Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm
推荐答案
嗨Greg,
我会咨询我的同事这个问题,需要一些时间。非常感谢您的耐心。
I will consult my colleagues on this question, and it will take some time. Your patience will be greatly appreciated.
问候,
Jeffrey
这篇关于Word2013中的CommandBar弹出行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!