How to work with the Next Paragraph on Word VBA

半腔热情 提交于 2020-07-09 12:01:11

问题


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

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


回答1:


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.



来源:https://stackoverflow.com/questions/45241554/how-to-work-with-the-next-paragraph-on-word-vba

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!