Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Help porting Cycling through document pages to C# please

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 23 Jan 2006 23:30 GMT
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 :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.