Best way to report VBA failures in an .XLSM

Plasmech

New Member
Joined
Oct 26, 2021
Messages
44
Office Version
  1. 365
Platform
  1. Windows
I want the users of an .XLSM that I manage to know immediately if VBA has stopped working.

My thought is to have a cell with text content "VBA FAULT" that would be suppressed/hidden by a line of VBA code.

A) Is this possible
B) How is it done
C) Any better ideas?

Thanks for any replies.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
The tricky part is that in order to log/report something like that (automation), you would probably need VBA enabled!
Obivously, if VBA is not enabled, you cannot have automation.

What I have seen some people do is to make all sheets/data (except for a cover sheet) VERY HIDDEN, and the other sheets are only exposed if VBA has been enabled.
The way they do this is to have "Workbook_Open" event procedure code (which runs automatically upon opening) that will unhide all the sheets.
If VBA code is not enabled, this macro does not run, and the sheets are not unhidden (not VERY HIDDEN sheets can not be seen/unhidden using typical manual unhide processes).
They then have "Workbook_Close" event procedure code that rehides the sheet and saves the file.

So, if they do not enable VBA code/macros, they really cannot do much of anything with the file.
 
Upvote 0
The tricky part is that in order to log/report something like that (automation), you would probably need VBA enabled!
Obivously, if VBA is not enabled, you cannot have automation.

What I have seen some people do is to make all sheets/data (except for a cover sheet) VERY HIDDEN, and the other sheets are only exposed if VBA has been enabled.
The way they do this is to have "Workbook_Open" event procedure code (which runs automatically upon opening) that will unhide all the sheets.
If VBA code is not enabled, this macro does not run, and the sheets are not unhidden (not VERY HIDDEN sheets can not be seen/unhidden using typical manual unhide processes).
They then have "Workbook_Close" event procedure code that rehides the sheet and saves the file.

So, if they do not enable VBA code/macros, they really cannot do much of anything with the file.
Hi Joe,

First, my apologies for the delayed response.

Thank you for the reply.

Correct me if I'm wrong, but if VBA is running, it will have the ability to hide the "FAULT" cell.

If it's not running, it won't, and thus the FAULT cell will be visible.

Am I over-simplifying this?
 
Upvote 0
Hi Joe,

First, my apologies for the delayed response.

Thank you for the reply.

Correct me if I'm wrong, but if VBA is running, it will have the ability to hide the "FAULT" cell.

If it's not running, it won't, and thus the FAULT cell will be visible.

Am I over-simplifying this?
Yes, you can have VBA hide certains rows or columns, dependent upon cell values.

There is a Workbook_Open event, which runs automatically when a file is first opened.
I imagine that is probably where you would want VBA like this to go.
Just bear in mind that if the column/row is already hidden, and VBA is not enabled, the column/row cannot be automatically unhidden.
 
Upvote 0
Yes, you can have VBA hide certains rows or columns, dependent upon cell values.

There is a Workbook_Open event, which runs automatically when a file is first opened.
I imagine that is probably where you would want VBA like this to go.
Just bear in mind that if the column/row is already hidden, and VBA is not enabled, the column/row cannot be automatically unhidden.
Looks like I could dedicate Row 1 as my FAULT row, and add:

Rows(1).Hidden = True

to the Workbook_Open code.
 
Upvote 0
Looks like I could dedicate Row 1 as my FAULT row, and add:

Rows(1).Hidden = True

to the Workbook_Open code.
And you may want to unhide it on the Workbook_Close event, to ensure it is unhidden from the start the next time it is opened.
I usually add a "ActiveWorkbook.Save" command after that too, to ensure it is saved that way.
 
Upvote 0
And you may want to unhide it on the Workbook_Close event, to ensure it is unhidden from the start the next time it is opened.
I usually add a "ActiveWorkbook.Save" command after that too, to ensure it is saved that way.
Understood. I'll give this a go.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,823
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top