将拼写检查合并到Word宏中 [英] Incorporating spellcheck into a Word macro

查看:206
本文介绍了将拼写检查合并到Word宏中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在Word 2003中创建一个VBA宏,它将现有的拼写检查与其他一些代码相结合。我想要的是用一个新的按钮替换默认的拼写检查按钮,该按钮将执行某些操作,然后以与用户按下普通拼写检查按钮完全相同的方式运行拼写检查。我的第一次尝试是使用

ActiveDocument.CheckSpelling

但这是一个略有不同的对话框,没有语法复选框,并且在拼写检查完成时没有给出通知。我现在正在使用
Application.Dialogs( wdDialogToolsSpellingAndGrammar )。显示

哪个更好,但它仍然没有完成时发出通知。显然我可以使用MsgBox解决这个问题,但我担心的是使用Application.Dialogs( wdDialogToolsSpellingAndGrammar )之间可能存在其他差异。显示与使用标准拼写检查按钮。是这样的吗?有没有办法以与非程序标准按钮相同的方式以编程方式调用拼写检查?谢谢。

I'm currently trying to create a VBA macro in Word 2003 that combines the existing spellcheck with some other code. What I want is to replace the default spellcheck button with a new button that will perform certain actions, then run spellcheck in exactly the same way as if the user pressed the normal spellcheck button. My first attempt was to use

ActiveDocument.CheckSpelling

but this is a slightly different dialog without the grammar checkbox, and no notification is given when spellcheck is completed. I'm now using

Application.Dialogs(wdDialogToolsSpellingAndGrammar).Show

Which is better, but it still doesn't give notification on completion. Obviously I can use MsgBox to get around this, but my worry is that there may be other differences between using Application.Dialogs(wdDialogToolsSpellingAndGrammar).Show versus using the standard spellcheck button. Is this the case? Is there a way to programmatically invoke the spellcheck in a way identical to the non programatic standard button? Thanks.

推荐答案

你好,

如果你想重新指挥你的电话到内置按钮我有另外一个想法,就是使用CommandBarControl.Execute方法,它的行为就像用户点击按钮一样,代码应该是这样的:

子栏( ))Dim cbar As Office.CommandBarControl
Set cbar = Application.CommandBars.FindControl(Type:= Office.MsoControlType.msoControlButton,ID:= 2566)'2566是Check Spelling按钮的ID。 />cbar.Execute
End Sub

谢谢

Hello,

If you want to just re-direct your call to the built-in button I've got another idea, that is, use CommandBarControl.Execute method, it behavior exactly like user click on the button, to code should goes like this:

Sub bar()
Dim cbar As Office.CommandBarControl
Set cbar = Application.CommandBars.FindControl(Type:=Office.MsoControlType.msoControlButton, ID:=2566) '2566 is the ID of Check Spelling button.
cbar.Execute
End Sub

Thanks


这篇关于将拼写检查合并到Word宏中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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