在Word VBA中发送BACKSPACE击键 [英] Send BACKSPACE keystroke in Word VBA

查看:514
本文介绍了在Word VBA中发送BACKSPACE击键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Word VBA中编写了一些代码,最后我需要1个退格键.这是如何实现的?

I have made some code in Word VBA and at the end I need 1 backspace keytroke. How is this achievable?

推荐答案

发送退格键的简单方法(但不是最可靠的解决方案):

The simple way to send a backspace (but not the most robust solution) :

SendKeys ("{BACKSPACE}")

一种更安全的方法:

Selection.MoveLeft Extend:=wdExtend
Selection.Delete

如果已经选择了某些内容,而您只想删除最后一个字符,则在前面加上:

If something is already selected, and you want to delete just the last character, preface the above by :

Selection.Collapse wdCollapseEnd

要转到当前页面的开头:

To go to the start of the current page :

ActiveDocument.GoTo(wdGoToPage, wdGoToRelative, 0).Select

这篇关于在Word VBA中发送BACKSPACE击键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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