![]() The part you now have needs thorough testing first. Consider this code a placeholder.įor your purposes code like this might do the job, perhaps.Paragraphs(1).Style = Head1 Actually, that is rather a different question, and I urge you not to rush for this result too fast. In my above sub there is just random code (extending the Rng by two preceding words and formatting everything as bold italics). This difference could be physical, like you didn't write the entire length of the text in the criteria, or technical, like excluding paragraph marks. But before you can do so you should deal with the difference between the text you found and the text you want to format. If you want to cross-reference your headings, you can do this the same way you add a cross-reference to a caption except that you will choose Heading. In the 'Follow number with' dropdown, select Space instead of Tab character. To have a space instead, click on More> to expand the dialog. If the text was found you want to assign a style to it. By default, the number will be followed by a tab. If the text was found the found text (that is Rng.Text) is printed to the Immediate window, otherwise the original text Crits(i) with "didn't find". ![]() The second half of the sub deals with the outcome of the search. If the item is found you now have a handle on it by the name of Rng. ![]() But now the text is fed to the Find method which assigns the found text to the Rng range. The first half of the procedure will find each of the search criteria in your document using the same kind of loop as you already know from the test procedure. Execute FindText:=Crits(i), Forward:=True, _ It's just the infrastructure for testing and getting ready. Now you are ready to try to actually work on your document. Use the code below to test the above function. I shall add some practical concerns below. In theory it is enough if they are unique within the document. You can add as many elements as you wish. ' than the index because the latter starts at 0 ' observe that the actual number of elements is one greater ' the number of elements actually declared: ' The number of elements in the Dim statement must be equal to It might look like this:- Private Function SearchCriteria() As String()ĭim Fun(6) As String ' Fun = Designated Function return value Create a separate function for this purpose. Headers based on the chosen heading style will be created throughout your document.įind details of our Microsoft Word training in the London area, UK.įind details of our Microsoft Word training in the Dorset, Hampshire, Wiltshire areas, UK.įind details of our Microsoft Word training in the Sydney area of Australia.If there is no way in which you can identify the heads you want automatically you may have to write everything once. In the Style name columns select the style you want to use in your headers. Click Insert – Field and select the StyleRef field.Click View – Header and Footer to open the header.Headers based on the chosen heading style will be created throughout your document. ![]() From the Field properties Style name section, click on the heading style to be used in your headers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |