开发者

how to move to the next section in word using c#

I want to know how can I move to the section in my document using C#.

I have 3 or more sections in my document. I know how to move one page at a time using:

object lineCount = Word.WdUnits.wdLine;

object countPage = 1;

wordApp.Selection.MoveDown(ref lineCount, ref countPage, ref MISSING);

I'll try to loop until I found a new section with this:

while() //condition to check if found a new section

{

    wordApp.Selection.MoveDown(ref lineCount, ref countPage, ref MISSING);    

}

But I don't know what 开发者_开发百科condition should I use.

I hope someone here can help me, I you have better solution please let me know.tnx


In VBA code it is

Selection.GoTo What:=wdGoToSection, Which:=wdGoToNext, Count:=1

or even simpler

Selection.GoToNext wdGotoSection

In C# you could use

wordApp.Selection.GoToNext(Word.WdGoToItem.wdGoToSection);

You don't have to create an object for Word.WdGoToItem.wdGoToSection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜