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,
Cindy M -WordMVP- - 24 Jan 2006 16:24 GMT
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:
[quoted text clipped - 25 lines]
> 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 :-)