Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Papou,
Parce que on parle francais ici, je n'avais pas change le Sub. La saveur est plus delicieuse en francais. ;) Mais, malheuresement, il marche trop lentement pour mon objet. En fin, j'ai decide de traiter l'erreur qui se presente avec un "Resume Next" declaration. Simple! Merci encore. Sprinks "papou" wrote: Hello Sprinks Here's one way I use (please apologise for its beeing in french but you will easily find translation I am sure) HTH Cordially Pascal Sub Recherche_Macro() 'Ajouter une référence Ã* 'Microsoft VisualBasic For Application Extensibility 5.3 (Menu Outils|Références de l'éditeur VBA) If ActiveWorkbook.Name = ThisWorkbook.Name Then MsgBox "Le classeur actif ne doit pas contenir la macro Recherche_Macro" _ , vbInformation + vbOKOnly, "Arrêt" Exit Sub End If Dim Saisie, LeNom As String Saisie = InputBox("Saisir le nom de la macro cherchée" & vbLf & "en respectant les majuscules / minuscules") If Saisie = "" Then Exit Sub LeNom = "Sub " & Saisie Dim VBCodeMod As CodeModule Dim StartLine As Long Dim RechercheLaMacro Dim i As Integer, y As Integer For i = 1 To ActiveWorkbook.VBProject.VBComponents.Count Set VBCodeMod = ActiveWorkbook.VBProject.VBComponents(i).CodeModul e With VBCodeMod For y = 1 To .CountOfLines StartLine = .CountOfDeclarationLines + 1 RechercheLaMacro = .Find(LeNom, StartLine, 1, .CountOfLines, -1, True, True, False) Next End With Next If RechercheLaMacro = True Then GoTo trouve Else GoTo pastrouve End If Exit Sub trouve: MsgBox "La macro " & Saisie & " est bien dans le classeur " & ActiveWorkbook.Name Exit Sub pastrouve: MsgBox "La macro " & Saisie & " n'est pas dans le classeur " & ActiveWorkbook.Name Exit Sub End Sub "Sprinks" a écrit dans le message de news: ... Can anyone tell me how to test if a given string is a valid macro name? Thank you. Sprinks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Testing Spreadsheet Cells while in a Macro | Excel Discussion (Misc queries) | |||
Testing Print Macro | Excel Programming | |||
Run only part of a macro for testing | Excel Programming | |||
Testing in a macro for bad range name? | Excel Programming | |||
Macro Date Testing | Excel Programming |