This error is caused by a security option in Excel meant to deliberately lock out programmatic access to Microsoft Visual Basic for Applications (VBA) unless a user chooses to permit such access.


To resolve:

  1. Open a blank workbook in Excel.
  2. Go to File > Options > Trust Center
  3. Click on Trust Center Settings... 
  4. Under Macro Settings, make sure Trust access to the VBA project object model is checked.