![]() |
Word Search in VBE (True/False Solution)
Does anyone know how to search for a word in VBA modules? That is, I want to
do a search for a given word. I want to have a binary solution (True/False). I want to be able to search all modules in a given workbook. I would also want to be able to search workbook and worksheet modules as well. Thanks |
Word Search in VBE (True/False Solution)
Hello you may try Sub rechercheVBE() 'activate Visual basic For Application Extensibility 5.3 Dim i As Integer, x As Integer Dim Fichier As String, Recherche As String, Msg As String Dim Ligne As String Dim VBCmp As VBComponent Fichier = "TheWorkbook.xls" Recherche = "theWord" For Each VBCmp In Workbooks(Fichier).VBProject.VBComponents Msg = VBCmp.Name x = Workbooks(Fichier).VBProject.VBComponents(Msg).cod emodule.CountOfLines For i = 1 To x Ligne = Workbooks(Fichier).VBProject.VBComponents(Msg).cod emodule.Lines(i, 1) If InStr(1, Ligne, Recherche, vbTextCompare) Then MsgBox "True" Exit Sub End If Next Next VBCmp MsgBox "False" End Sub regards michel -- michelxld ------------------------------------------------------------------------ michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367 View this thread: http://www.excelforum.com/showthread...hreadid=387484 |
All times are GMT +1. The time now is 07:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com