Microsoft Excel - How to remove this error Method 'VBProject' of object '_workbook' failed in VBA

Asked By Tarun Dabral on 18-Oct-12 12:57 AM
I have a macro which is shows error.This error maybe reference error.
The error shows in Line no. 6 and already colored in red.

The Code is given below:

Public Sub CheckReferences()
    Dim i As Integer
  
    For i = 1 To ThisWorkbook.VBProject.References.Count
      If ThisWorkbook.VBProject.References(i).IsBroken Then
        ThisWorkbook.VBProject.References.Remove _
        ThisWorkbook.VBProject.References(i)
        Exit For
      End If
    Next i
  
    If Application.Version = "9.0" Then
      ThisWorkbook.VBProject.References.AddFromFile _
      "C:\Program Files\Microsoft Office\Office\msoutl9.olb"
    Else
      ThisWorkbook.VBProject.References.AddFromFile _
      "C:\Program Files\Microsoft Office\Office10\msoutl.olb"
    End If
End Sub
wally eye replied to Tarun Dabral on 18-Oct-12 08:19 AM
In the Trust Center, Macro Settings, check the "Trust access to the VBA project object model"...
Tarun Dabral replied to wally eye on 01-Nov-12 01:16 AM
Thanks