![]() |
Code Crashing
When I run the following code it sometimes crashes on the first line
after the for loop start. The code adds/removes some menu items from the 3 cell right click menus(There are 3 right click cell menus, one for when a cell or area of cells are selected, one for entier row(s) selected, and one for entire column(s) selected). I can get it to run the line of code by debugging, then making the particular menu show once, and then resuming the code. I can't get the error to repeat consistently. Any ideas are appreciated. Thanks. Code:
Sub Setup_Right_Click_Items() |
Code Crashing
Well let me nitpick it...
Use Option Explicit as the first line in the module. Make sure the code is in a standard module. Use Application.CommandBars instead of CommandBars Declare the i variable... Dim i as Long Declare MenuArray as an array... Dim MenuArray() as Long Try your code without using the myIndex variable. All of the new menu items will then be added to the bottom of the menu. Don't run your code in Page Break Preview mode. There is a separate right-click "Cell" menu that functions there. I would also have two separate subs, one to delete the menus and one to add the menus. -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "John" wrote in message When I run the following code it sometimes crashes on the first line after the for loop start. The code adds/removes some menu items from the 3 cell right click menus(There are 3 right click cell menus, one for when a cell or area of cells are selected, one for entier row(s) selected, and one for entire column(s) selected). I can get it to run the line of code by debugging, then making the particular menu show once, and then resuming the code. I can't get the error to repeat consistently. Any ideas are appreciated. Thanks. -snip- |
Code Crashing
Tried all of that. No luck =/ I have been able to make it repeatedly
crash trying to do add the items to the row right click menu by opening excel and then loading the addin (I have the code placed in a standard module in the add on xla file). I know I could let it just add it to the end of the right click menus, but that's not where I want it. That and I know it worked fine when I first wrote the code, so not sure why its crashing now. I'm running MS Office 2003, SP3. |
Code Crashing
On Feb 8, 4:16*pm, John wrote:
Tried all of that. *No luck =/ *I have been able to make it repeatedly crash trying to do add the items to the row right click menu by opening excel and then loading the addin (I have the code placed in a standard module in the add on xla file). *I know I could let it just add it to the end of the right click menus, but that's not where I want it. *That and I know it worked fine when I first wrote the code, so not sure why its crashing now. *I'm running MS Office 2003, SP3. Replacing the offending line with the following code seems to have "fixed" the problem. On Error Resume Next Set myIndex = Application.CommandBars(MenuArray(i)).Controls("In sert...") Set myIndex = Application.CommandBars(MenuArray(i)).Controls("In sert") On Error GoTo 0 |
All times are GMT +1. The time now is 02:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com