Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't my custom Excel menu work any more?

Status
Not open for further replies.

yalamo

Technical User
Sep 22, 2002
244
IL
I am using Office 2000.

I have an Excel workbook with a custom menu (using the "CreateMenu" macro I found in: This has worked well for about a year, and survived one or two changes I made in the MenuSheet referred to in the above link, which resulted in the corresponding changes in the custom menu, and they worked. The custom menu opened up with the workbook, since I used the Workbook_Open subroutine in the ThisWorkbook code module, as recommended in the link.

A few days ago, I decided to make another change, which required the addition of a new macro. Since I didn't want to upset anything in the old spreadsheet, I saved it under a new name, and started working on that. I wrote the new macro, and added a sheet to which this would used to add new data. Everything seemed to work, and I then changed the Menusheet so that it would include the new macro. I tried it a couple of times, and it worked, adding the data properly to the new sheet.

I then used the revised custom menu, and new macro to add more data to rhe new sheet That worked as well, and I closed Excel, thinking everything was OK.

The next time I opened the new workbook, I got the Windows popup that says "Microsoft Excel for Windows has encountered a problem and needs to close. We are sorry for the inconvenience." So now I couldn't open up my new Workbook!

I then found that if I opened the old Workbook (with the old name) first, amd then the new workbook, everything (including the new custom menu and new macro) worked fine. If I then closed the old workbook, the Custom menu in the new workbook would disappear. If I then ran the CreateMenu macro manually, it came back again, and there was no problem using it. This leads me to believe that the problem is in the "Workbook_Open()" subroutine. But there is nothing there except a call to the CreateMenu macro, and is identical to the "Workbook_Open()" subroutine in the old workbook.

Can anyone give me any pointers on where to look to fix this problem? I would not call myself a very experienced VBA Excel programmer. As a matter of fact, the old workbook was the first time I had written VBA macros, but in the end, they worked, and reliably for almost a year.
 
Yalamo,

Did you change all of the references in the new macro? If you did a straight copy you've probably got references to the original worksheet in your new worksheet macro. That would cause the problem you describe.
 
WalkerEvans, thanks, but I don't believe that's the problem. I don't have any explicit references to the workbook name in either Workbook_Open or CreateMenu subroutines. Instead, in the CreateMenu subroutine, I refer to "ThisWorkbook", as in:
Code:
Set MenuSheet = ThisWorkbook.Sheets("Last")

Also, the fact that I can run the CreateMenu subroutine successfully when the Workbook is not being opened indicates that's not the problem.

Any other ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top