Excel : modification du code module

odenisf59 Messages postés 4 Date d'inscription jeudi 15 février 2007 Statut Membre Dernière intervention 1 octobre 2008 - 1 oct. 2008 à 10:18
odenisf59 Messages postés 4 Date d'inscription jeudi 15 février 2007 Statut Membre Dernière intervention 1 octobre 2008 - 1 oct. 2008 à 16:41
Bonjour,

J'ai plusieurs centaines de fichiers XLS dans lequels le code contenu dans les parties modules/vba sont à mettre à jour.

Je suis à la recherche d'un automatise pour substituer le "mauvais" code  par le bon code ?
peut on manipuler la partie code des classeurs ?

merci

2 réponses

bigfish_le vrai Messages postés 1835 Date d'inscription vendredi 13 mai 2005 Statut Membre Dernière intervention 20 novembre 2013 15
1 oct. 2008 à 16:36
Salut,

pas dans le bon theme ! pour le VBA c'est ici :

Thèmes / [forum-VISUAL-BASIC_1.aspx Visual Basic 6] / [theme-LANGAGES-DERIVES_287.aspx Langages dérivés] / [theme-VBA_244.aspx VBA] /

oui on peut ! pour avoir quelques exemples vas voir ici

Une chose importante :  tu dois activer la reference "Microsoft Visual Basic for Applications Extensibility 5.3" si tu ne sais
pas le faire manuellement tu peux toujours essayer d'utiliser le code suivant :

Sub ActiveRef() 'activation of the reference *Microsoft Visual Basic for Applications Extensibility 5.3*
    Dim MyRef As String, RefPath As String, TypeError As String, MsgTitle As String

    RefPath = "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6"
    MyRef = "Vbe6ext.olb"
    MyRef = Dir(RefPath & MyRef)
    If MyRef <> "" Then
        Application.DisplayAlerts = False
        On Local Error Resume Next
        ThisWorkbook.VBProject.References.AddFromFile RefPath & MyRef
        If Err = 1004 Then
            Err.Clear
            TypeError = " The Reference could not be added "
            TypeError = TypeError & " or the Trust access to Visual Basic Project is disable or both !" _
            & vbCrLf & vbCrLf & "In order to allow the activation of the references, follow the process below :" & vbCrLf _
            & vbCrLf & "Point to Macro on the Tools menu, and then click Security." _
            & vbCrLf & "On the Trusted Publishers tab, check the Trust access to Visual Basic Project box. " _
            & vbCrLf & vbCrLf & "For more information please contact Bigfish_le vrai"
            MsgTitle = "Reference Missing..."
        Else
            TypeError = " **Reference Activated** "
            MsgTitle = "Good News..."
        End If
        Application.DisplayAlerts = True
    Else
        TypeError = " Reference not found " & " _

            & vbCrLf & vbCrLf & "Please, check the file's name or the path specified !"
        MsgTitle = "Reference Missing..."
    End If
    Msgbox TypeError, vbExclamation, MsgTitle
End Sub

A+
0
odenisf59 Messages postés 4 Date d'inscription jeudi 15 février 2007 Statut Membre Dernière intervention 1 octobre 2008
1 oct. 2008 à 16:41
ok merci pour l'info
0
Rejoignez-nous