Set treeView_PopupMenu suddenly failed (vba); cured by re starting windows7. Nasty shock - seek advice re explanation/prevention.


In Excel 2010, I have recently built my first TreeView popup menu which enables procedures to be called when right clicking a tv node from a UserForm TreeView control. All was going fine ...

... Suddenly, earlier file versions (that worked well on previous days)  FAILED at the following step:

Set treeView_PopupMenu = Application.CommandBars.Add(name:="UserForm1Popup", _
                                                 Position:=msoBarPopup, _

Blood running cold - I re-started Windows 7 - and the problem disappeared.  
I have no clues re the failure, but does the evidence suggest the cause was outside the excel piece?

Has anyone had this experience? My piece is intended for distribution. I hope to understand what happened, to head-off the problem if possible, or arrange for a less disconcerting crash.

Can I do better than put in an error trap that directs the user to restart the computer?

I have continual AVG anti-viral cover. I carry our occasional checks with SuperAntiSpyware  (, but it was not on when this occurred.

I had to restart my PC yesterday because my old Logitech cordless mouse failed to drive the cursor (though it had a new battery).

The machine is not used for games/ TV, just work. My browser is google chrome.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is it possible that you had 2 files open with the same project / module names.  I'm not sure about Excel - but Word can really struggle when that happens...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kelvin4Author Commented:
I opened two excel file versions which were 99.99% identical (differing in file name and just a few lines of vba code).  Was that as fair test of your point? In the event, the files behaved perfectly regarding the operation of the tv popUp menu. But I  appreciate your suggestion.  Kelvin
Kelvin4Author Commented:
Also, pening the two versions in the same workbook caused no failure, Thanks.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Well - it's nice to be able to rule some things out too I guess ;-)

The only other things I can think of are:
- it was a co-incidence, office applications sometimes crash (not very helpful, but possibly the right answer)
- were you using break'points in your code for debugging, sometimes I've managed to crash word with a carefully placed breakpoint ;-)  
- were there any other add-ins that might have been interfering with your code?
Kelvin4Author Commented:
Will await other contributions; noted that yours was first!
No worries, I'm out of ideas - hope you find a root cause. Cheers,
Kelvin4Author Commented:
This was an open question, trawling for defensive ideas.
Thanks, Dr Tribos, for sharing your thoughts. As you say, maybe the crash was coincidence.
The problem did not ring any bells with others.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.