Help porting Cycling through document pages to C# please

M

Mike

Hi! I need to port the following code snippet from vba-programmer.com to
cycle through document pages:

http://www.vba-programmer.com/Code_Word/Cycling_through_Document_Pages.txt


MaxPages = Selection.Information(wdNumberOfPagesInDocument)
For i = 1 To MaxPages
Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=i, Name:=""
ActiveDocument.Bookmarks("\page").Select
Next


Here's my code in C#:
object objWHAT =Word.WdGoToItem.wdGoToPage;
object objWHICH = Word.WdGoToDirection.wdGoToFirst;
object objCOUNT = null;
object NAME = "";



sel = doc.Application.Selection;
int MaxPages =(int)
sel.get_Information(Word.WdInformation.wdNumberOfPagesInDocument);

for (int i = 1; i <= MaxPages; i++)
{
objCOUNT = i;
sel.GoTo(ref objWHAT, ref objWHICH, ref objCOUNT, ref NAME);

// !!!!!!!!!!! How do I port this line ???????
ActiveDocument.Bookmarks("\page").Select

}

}

Thank you in advance,
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?TWlrZQ==?=,
// !!!!!!!!!!! How do I port this line ???????
ActiveDocument.Bookmarks("\page").Select
Untested, but I think roughly:

object objName = "\page";
Word.Bookmark bkm = doc.Bookmarks.get_Item(ref objName);
bkm.Range.Select();
I need to port the following code snippet from vba-programmer.com to
cycle through document pages:

http://www.vba-programmer.com/Code_Word/Cycling_through_Document_Pages.txt


MaxPages = Selection.Information(wdNumberOfPagesInDocument)
For i = 1 To MaxPages
Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=i, Name:=""
ActiveDocument.Bookmarks("\page").Select
Next


Here's my code in C#:
object objWHAT =Word.WdGoToItem.wdGoToPage;
object objWHICH = Word.WdGoToDirection.wdGoToFirst;
object objCOUNT = null;
object NAME = "";



sel = doc.Application.Selection;
int MaxPages =(int)
sel.get_Information(Word.WdInformation.wdNumberOfPagesInDocument);

for (int i = 1; i <= MaxPages; i++)
{
objCOUNT = i;
sel.GoTo(ref objWHAT, ref objWHICH, ref objCOUNT, ref NAME);


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top