We need to do this in two steps - by finding first the start and then the end of that range. We now need to get a Range object that includes all the text on that page. So now we know what page we're interested in. For this, we can use the Information method: pageNumber = Selection.Information(wdActiveEndPageNumber) However, if we want all the words on that page, then we need to work a little harder.įirst, let's find out what page the (start of the) selection is on. Word's Selection object has the properties of a Range, and if you simply wanted all the selected words, then this would be trivial ( Selection.Words!). I'll also answer using VBA because it's easier to play around with it in the VBA immediate window, and it's trivial to convert to C# when you need to (it's the same object model, after all). (Actually, since the selection can span several pages, let's define it as "the page where the active end of the selection is"). Let me re-define "current active (visible for user) page" as the page where the selection is. If I can make the question slightly easier, then perhaps I can answer it in a way that helps you. He may be viewing the end of one page and the start of the next, or several pages may be displayed - depending on his view settings. In part, that's because the user doesn't necessarily see only one page at a time. What's more, there's no easy way to tell what page is currently displayed. So, there is no "ActiveDocument.Pages(1)" sort of thing. Word's object model doesn't really have a "page" object, because the pagination of the document is constantly changing as you add and remove content (or change the font size, the paper size, etc.).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |