title: VBA - Auto check/uncheck microsoft script run time
body: <p>I had the following function that auto add <code>Microsoft Script Runtime</code> Reference to the Reference list. However, if the user already had included <code>Microsoft script runtime</code>, it will show error <code>Name conflicts with existing module,project, object library</code>.  </p>
  
  <p>How do I set an condition that auto adds <code>Microsoft script runtime</code> if it is not included in the reference and do nothing if it has already being added?</p>
  
  <pre><code>Private Function AddScriptingLibrary() As Boolean
  
  Const GUID As String = "{420B2830-E718-11CF-893D-00A0C9054228}"
  
  On Error GoTo errHandler
  ThisWorkbook.VBProject.References.AddFromGuid GUID, 1, 0
  AddScriptingLibrary = True
  Exit Function
  errHandler:
  MsgBox Err.Description
  
  End Function
  </code></pre>