![]() 'The code uses late binding, so no reference to an external library is required. 'cases prefer the SearchTextInPDF macro if you have only ONE WORD to find! 'Note that in some cases it doesn't work (doesn't highlight the text), so in those ![]() 'The macro uses the FindText method (see the code below for more info). 'The macro opens the PDF, finds the specified text (the first instance), scrolls so 'This macro can be used to find a specific TEXT (more than one word) in a PDF document. The FindTextInPDF macro uses the FindText method to find a text phrase inside a PDF document. If you try to use it with Adobe Reader, you will get an error. Needless to say that the VBA code that you will find below works ONLY with Adobe Professional. You will either go with the unreliable FindText method or with the slow JSO approach (only if you are searching a single word). Unfortunately, there is no straight solution to this problem, but only a sort of compromise. In large PDFs, it might be considerably slower. It’s quite a reliable method.Ĭons: If you search two words, for example, in the PDF, it doesn’t find anything. Pros: Useful when searching a SINGLE WORD in the PDF document (not a phrase). ![]() This solution’s name comes from the JavaScript Object (JSO) that performs all the hard work. If the comparison is true, the word is highlighted otherwise, the next word proceeds. The idea is to loop through all the PDF document words and compare each word with the text we are searching for. Unlike FindText, the JSO approach doesn’t use a “native method,” but, in reality, it is two loops, one inside the other. Although it might be an easy and fast method, unfortunately, it is not 100% reliable. Pros: Useful when searching a text phrase in the PDF document (more than one word).Ĭons: In some cases, it doesn’t work (it doesn’t highlight the text). If false, it matches partial words.īeginning: If true, the PDF search begins on the first page of the document. Whole words only: If true, the PDF search matches only whole words. Text to find: The text that is to be found.Ĭase sensitive: If true, the PDF search is case-sensitive. If the return value is true, it finds the specified text (the first instance), scrolls until the word is visible, and highlights it. Syntax: object.FindText(text to find, case sensitive, whole words only, beginning)ĭescription: The FindText method returns true if the text was found or false if it was not. In general, there are two possible solutions to this problem (OK, maybe there are other solutions that I am not aware of), both of which have their advantages and disadvantages. Is that even possible?” So, in this post, I will try to answer this question. Jason wrote: “I am trying to perform a PDF search from Excel. This post’s motive came from an email question that I received from a blog reader during the previous weekend.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |