Hello. What you ask is possible of course, however, the technique to use, differs. The most important thing is, the format of your "active document". Is it an XLSX file? A Wor docx file? It depends.
I can give you ideas if you want. I can implement auto-text detection function to any office software using VBA.
Message if interested. Thank.s