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