'Macro Created by : Bigfish_le vrai 'Date : 02-20-2008 'V2.0 ' Option Explicit Sub ActiveRef() 'activation of the reference *Microsoft Visual Basic for Applications Extensibility 5.3* Dim MyRef As String, RefPath As String, TypeError 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 " MsgBox 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 ...", vbExclamation, "Reference Missing..." TypeError = " The Reference could not be added " Else TypeError = " **Reference Activated** " End If Application.DisplayAlerts = True Else TypeError = " Reference not found " End If Application.DisplayAlerts = False RecError (TypeError) End Sub Sub RecError(ByVal TypeError As String) 'error report Dim CMDAppli As Double, CurrentPath As String, ErrorFile As String, MsgError As String, NbSub As Long CurrentPath = ThisWorkbook.Path & "" ErrorFile = "Error.txt" MsgError = Now & TypeError & ThisWorkbook.Name CMDAppli = Shell("cmd.exe /c echo " & MsgError & " >> " & ErrorFile, 0) End End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question