Word VBA, Select whole document minus first page

天大地大妈咪最大 提交于 2019-12-24 04:43:29

问题


I know you can select the whole document like so

oWord.oDoc.ActiveWindow.Selection.WholeStory

What would be the syntax to select the whole document minus the first page?

Context: Excel runs all the code and outputs ranges direct to word to build a report. Reports can be any number of pages and the amount of pages is not known. This code would run as the last piece so document would be built by this point.


回答1:


The following code selects everything from the second page onward:

Dim startRan As Range

Selection.HomeKey unit:=wdStory
Set startRan = Selection.GoTo(What:=wdGoToBookmark, Name:="\page")

oDoc.Range(startRan.End, startRan.End).Select
Selection.EndKey unit:=wdStory, Extend:=wdExtend


来源:https://stackoverflow.com/questions/31697918/word-vba-select-whole-document-minus-first-page

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