Can't perform requested operation (Error 17)
An operation can't be carried out if it would invalidate the current state of the project. This error has the following cause and solution:
The requested operation would invalidate the current state of the project. For example, the error occurs if you use the References dialog box to add a reference to a new project or object library while a program is in break mode.
Stop execution of the current code, and then retry the operation.
An attempt was made to programmatically modify currently running code. For example, your code may have tried to read code from a disk file into a currently running module.
Although you can modify modules in the project while they aren't actually running, you can't make modifications to a running module. To make such changes, you must stop the module from running, make the additions or changes, and then restart execution.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.