02-05-2019 07:43 AM
02-05-2019 07:43 AM
Feature request: being able to use the debug button when the vba code is protected from viewing
Problem: When a user encounters an error and the vba project is protected from viewing, currently the debug button is disabled and the user can only press "End" to stop the code. As a developer, this makes it cumbersome to troubleshoot - it's not always easy to reproduce the bug, which currently involves ending the code, unlocking the project, and then restarting the code hoping that the same error will occur again.
Solution: Always allow the debug button to be pressed, even if the project is locked from viewing - but if the project is locked from viewing, prompt the user for the vba password to unlock the code.
That would allow me to troubleshoot right at the moment the error occurs, rather than going through the hassle of attempting to reproduce it.
02-05-2019 09:33 AM
If you develop a VBA program to use it personally, then you don't have to block the project from view.
Make it always viewable to you.
But, if you send this project to someone else to use as an end user, the end user should not be able to view the source code and debug it.
Even the error message, the end user should not see it!
You have to use some error handling techniques to replace any possible error message with another helpful message box or form to prompt the end user to report the problem and its details to you as a developer.
02-05-2019 11:51 PM
The end user shouldn't be able to see and debug the code, but I should be able to on the end user's PC, at the very moment the error occurred - instead of being forced to unreliably attempt to reproduce it.
Error handlers make reproducing an error only harder to do - obfuscating the exact point in the code where the error occurred, and the circumstances that caused it to occur. I only use them to handle known/predicted errors.
I don't always want errors to be reported to me - I much prefer to be called on over as they occur to be able to analyse and troubleshoot them on the spot, in the moment and under the circumstances that the error occurred.
I can do that if the code is unlocked, but if the code is locked I have no such option, despite knowing the password to unlock the code - that doesn't help me if I'm not allowed to enter it to unlock the code without stopping the code using the 'End' button.
02-06-2019 09:40 AM
Okay, it makes sense to have the Debug button available even if the project is locked so that when you running into an error and the project is locked, you can click the Debug button to go into the project and enter the password to be able to debug the error, rather than disable the Debug button.
I think this is what you want.
But I suggest you post this request in the Excel’s Suggestion Box rather than here.