From: Jay Freedman on 26 Mar 2010 10:08 John wrote: > On Mar 25, 2:59 pm, "Graham Mayor" <gma...(a)REMOVETHISmvps.org> wrote: >> ActiveDocument.Bookmarks("\page").Range.Copy >> >> will copy the text of the current page to the clipboard, however a >> 'page' is a vague concept in Word and comprises of several elements. >> It may not be possible to copy all those elements together, so how >> successful this will be depends on what is on the 'page'. >> >> -- >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> Graham Mayor - Word MVP >> >> My web sitewww.gmayor.com >> Word MVP web sitehttp://word.mvps.org >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> >> "John" <helpme.c...(a)yahoo.com> wrote in message >> >> news:ea1b85e2-e799-4643-b770-140d4ad58470(a)y17g2000yqd.googlegroups.com... >> >> >> >>> Hi. >> >>> I want to use Control-F to just to a specific page. When I arrive at >>> that page, i want to copy all the text on that page only. It's >>> possible to do by manually, not sure if it can be done using a >>> macro. (if only there was a control-A that applied just to that one >>> page)- Hide quoted text - >> >> - Show quoted text - > > Now that I have the answer, it's great, but I'd like to try and teach > myself what > > ActiveDocument.Bookmarks("\page").Range.Copy > > means. Step-by-step. Can anyone recommend any books/video tutorials > where I can learn the basics of Visual Basic. I imagine it's a very > steep learning curve! > > Regards Hi John, Start at http://www.word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm. Also look at some of the other articles listed in http://word.mvps.org/FAQs/MacrosVBA.htm#BeginnersTips, and http://www.gmayor.com/installing_macro.htm. Let's take apart the current example, ActiveDocument.Bookmarks("\page").Range.Copy: - The keyword "ActiveDocument" means the Word document that currently has the focus (that is, where the letters would go if you started typing). If you have two or more documents open at the same time, ActiveDocument might refer to different documents at different times, even during a single macro run. - The period or dot should be read as "contains" or "has as a property or method". - In this case, the ActiveDocument contains a Bookmarks collection -- a list of all the bookmarks in that document. - The quoted string in parentheses is an "index" or identifier that chooses a single bookmark out of the Bookmarks collection. In this case, "\page" is a built-in bookmark (that is, you don't have to define it manually) that covers the contents of the page that contains the cursor (technically, the Selection object) at the time this command executes. As Graham said, this is a vague concept in Word because the page contents are constantly being recomputed on the basis of the text in the document, its formatting, the margins and orientation, graphics, manual breaks, etc. etc. and how the currently selected printer driver interprets all of that. Recapping, up to this point ActiveDocument.Bookmarks("\page") gets us a bookmark in the right location. - After the next dot, the Range keyword refers to an object defined by the location (starting and ending points) of the bookmark. The Range object has a ton of properties and methods for formatting and manipulating the text. It's worth opening the VBA help topic on the Range object and looking at the list of its members, and reading about any that seem interesting. - The last dot and the Copy keyword refer to the command to copy the contents of the page to the clipboard. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |