By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,474 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,474 IT Pros & Developers. It's quick & easy.

Find Text on PDF

P: 2
Hi

I am using a Web Browser control to display a pdf file and I would like to find a way to use the find functionality from the pdf viewer, using vba code, to find a tag inside of the pdf.

In detail (see screenshot): I have one continuos subform (subform1) with record selectors. Whenever I click on a record on the subform1, I would like to use vba to get the string LineID and make a search on the pdf viwer using the "Find" tool.



How can I pass the string "Line Id" from the subform to the web browser (pdf viwer) and automatically perform the search?
Attached Images
File Type: jpg FindPdf.jpg (38.4 KB, 452 views)
Nov 18 '11 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,679
There appears to be no easy way to accomplish this, but I did arrive at a rather bizarre solution involving SendKeys, a Programmed Delay, and simulated Keystrokes. I have tested it and it does work, but it may be a little flaky.
  1. Declaration in a Standard Code Module
    Expand|Select|Wrap|Line Numbers
    1. Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  2. Code to execute:
    Expand|Select|Wrap|Line Numbers
    1. 'If nothing to find, get out!
    2. If IsNull(Me![txtFind]) Then Exit Sub
    3.  
    4. Me![WebBrowser1].SetFocus           'Set Focus to the Web Browser Control (WebBrowser1)
    5.  
    6. SendKeys "^f", True                 'CTRL+F will place Cursor in Find Box, in Browser (WAIT)
    7.   Sleep 3000                        'Delay 3 Seconds
    8. SendKeys Me![txtFind], True         'Type in the Text in the Text Box txtFind on the Form (WAIT)
    9. SendKeys "{ENTER}"                  'Simulate pressing the ENTER Key
  3. Text indicated in [txtFind], if it exists in the *.pdf Document, will now be highlighted.
Nov 24 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.