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.
- Open a blank workbook in Excel.
- Go to File > Options > Trust Center
- Click on Trust Center Settings...
- Under Macro Settings, make sure Trust access to the VBA project object model is checked.