如何在 Word VBA 上使用下一段 [英] How to work with the Next Paragraph on Word VBA

查看:70
本文介绍了如何在 Word VBA 上使用下一段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据下一个段落值执行操作,并使用以下内容

I'm trying to execute an action based on the next paragraph value with the following

If ActiveDocument.Paragraph.Next(wdParagraph).Range.Characters.Count > 1 Then

但是,我认为我没有正确使用 .Next.我如何在这行代码中使用它?

However, I think I'm not using the .Next correctly. How can I use it whithin that line of code?

推荐答案

Next 方法似乎并非在 Word VBA 的所有版本中都可用.根据此站点,它特定于 Office 365.https://msdn.microsoft.com/en-us/vba/word-vba/articles/paragraph-next-method-word但是,您也没有正确使用它.上面的站点显示了以下语法.设置 myRange = ActiveDocument.Paragraphs(1).Next(Count:=n).Range因此,逻辑是定义您现在所在的段落 (Paragraphs(1)) 并指定您正在按相同的参数计算段落数.因此 Next(wdParagraph) 不需要指定计数的主题.相反,wdParagraph 将表明您希望指定您所在位置的第 4 段 (wdParagraph = 4),如果您在语法中早先提供了该信息.

The Next method doesn't appear to be available in all versions of Word VBA. According to this site it is specific to Office 365. https://msdn.microsoft.com/en-us/vba/word-vba/articles/paragraph-next-method-word However, you are also not using it correctly. The above site shows the following syntax. Set myRange = ActiveDocument.Paragraphs(1).Next(Count:=n).Range So, the logic is to define the paragraph where you are now (Paragraphs(1)) and specify that you are counting paragraphs by that same parameter. Therefore Next(wdParagraph) isn't required to specify the subject of your count. Instead, wdParagraph would indicate that you wish to specify the 4th paragraph from where you are (wdParagraph = 4), if you had provided that information earlier on in your syntax.

这篇关于如何在 Word VBA 上使用下一段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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