vba 将光标移到表格外

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4212462/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:19:13  来源:igfitidea点击:

Move cursor outside of table

vbams-word

提问by rana123

I am using VB to write a macro in Word. what i need to do is, if i am within a table i need to move out of it. so if

我正在使用 VB 在 Word 中编写一个宏。我需要做的是,如果我在一张桌子内,我需要搬出它。因此,如果

x = Selection.Information(wdWithInTable)

then i have to move out.

那我得搬出去了。

What is the code to move out of the table?

移出表的代码是什么?

回答by Tom Juergens

Well, that depends of course exactly where you want to move to - before or after the table or somewhere quite different; your question is a bit vague.

嗯,这当然取决于您想要移动到的确切位置 - 在桌子之前或之后或完全不同的地方;你的问题有点含糊。

This code will get you out of the table and put the text cursor directly behind it:

此代码将使您离开表格并将文本光标直接放在其后面:

Selection.Tables(1).Select
Selection.Collapse WdCollapseDirection.wdCollapseEnd