VBA: Excel crashes opening file with comments.

MichaelSchulz

Board Regular
Joined
Apr 10, 2014
Messages
64
I have an Excel file with a VBA project that had been working just fine until recently. I have finally tracked the problem but it does not make much sense:

At one point, the code within the Excel file opens another file to get a value—this second file is provided by an outside third-party.
When the code attempts to open the most recent file, Excel crashes. It just closes entirely. No option to save.

I have found that this other file contains cell comments; if I remove all of these comments, then the process runs fine.
Nothing crashes. If just one of these cell comments remain, the process crashes when VBA attempting to open the file.

Why should the existence of cell comments cause my VBA process to crash Excel?
My VBA project was created in Excel Profession Plus 2013—what if this third-party file was created by a more current version of Excel? Is there something about cell comments in the most recent versions of Excel that might cause a problem when being manipulated by VBA in an older version of Excel? Seems a stretch but I cannot think of any reason why cell comments should be the reason the process should crash when attempting to open the file.

Does anyone have any ideas?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Update:
So while there may be some sort of difference between cell comments in Excel 2013 and latter versions, that does NOT appear to be the issue.

I re-created the third-party file from scratch using Excel 2013 and inserted normal comments. These cell comments also caused my VBA project to crash.

What is it about cell comments that this should happen? What should I do different to manage this?
 
Upvote 0
Hello. Do you need still need help with this or have you managed to solve this?

Something you said reminded that there is an issue with VBA and Comments and Notes. What used to be Comments are now Notes, but in VBA, they're still referred to as Comments. What are referred to as Comments on the Ribbon, are called CommentThreaded (I think) in VBA. I'm surprised that its causing the crashes you're experiencing - it seems almost as there is some API declaration call problems. Anyway, was just a thought.
 
Upvote 0
Hello. Do you need still need help with this or have you managed to solve this?

Something you said reminded that there is an issue with VBA and Comments and Notes. What used to be Comments are now Notes, but in VBA, they're still referred to as Comments. What are referred to as Comments on the Ribbon, are called CommentThreaded (I think) in VBA. I'm surprised that its causing the crashes you're experiencing - it seems almost as there is some API declaration call problems. Anyway, was just a thought.
I did managed to solve it but it was WEIRD.

The file being opened is emailed to us from a third-party. When opening the file normally, it opens in protected mode.

The solution was that I had to change the VBA code to open the file explicitly in protected mode and then—after all the needed code had been executed—also code explicitly to close the protected view window instead of a simple close file statement.

I still have no idea why the existence of Comments (now Notes) would be a factor here.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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