To learn details about the current selection in a Word document

While controlling Word information automatically, you as a rule need to know somewhat about the as of now chose information. For example, you may need to realize what page the information lives on, what section the information is in, or what number of pages are in the present archive. Gathering such particular data just sounds scaring. In all actuality, it’s a straightforward errand for Visual Basic for Applications (VBA). The arrangement is to reference the Selection question’s Information property in the shape Selection.Information(information) where data speaks to various characterized parameters that arrival particular data about the present determination. Presently, there are some of these parameters. To see a total rundown, seek on Information Property in the Word Visual Basic Editor’s (VBE) Help. Or then again, in the VBE, press F2 to dispatch the Object Browser.

Enter Information in the Search Text control and snap Search. Doing as such will restore a few potential outcomes; Click the wdInformation class section to see an entire rundown of this present property’s parameters. There are any number of approaches to utilize this property, yet we’ll keep things straightforward by showing the aftereffects of a couple of proclamations in the Immediate window. In Word’s VBE, pick Module from the Insert menu and enter the accompanying code: Sub SelectionInformation() ‘Print data about choice. Debug.Print “Section: ” and _

Selection.Information(wdNumberOfPagesInDocument) End Sub Before running the code, ensure there’s a record open. At that point, come back to the VBE and press [Ctrl]+G to open the Immediate window (if fundamental). To run the code, click anyplace inside the real sub strategy and press F5.

Each Debug.Print articulation connects a depiction, for example, Column, Line, et cetera to the aftereffects of the comparing property and prints the outcomes to the Immediate window. This specific sub methodology isn’t intended to really accomplish something that you can instantly utilize in your own particular reports. Or maybe, it’s a prologue to the Information property. Since you know how to pass the fitting parameter, you can learn pretty much anything you have to think about the present choice in a Word report.

For More Posts Visit: office com setup

Leave a Reply

Your email address will not be published. Required fields are marked *