![]() |
Help - VBA Code execution in Excel
Can someone help me with the "How to" trigger a VBA code to set up a
menu if a particular workbook is opened? The reason that I need this code is that I have a workbook that is generate every week and would like to be able to generate a custom menu that every time that this particular workbook is open is generate a custom menu. The only way that I can do this is by adding the vba code in ThisWorkbook but because it is generate everytime the code is override. Suggestions please. Luis |
Help - VBA Code execution in Excel
Louis,
Properly controlling a custom menu is rather complex. You need to set things up to create the menu when the workbook is Opened or Activated, and the menu must be destroyed when the workbook is Closed or Deactivated. If the menu is to be associated only with certain worksheets in the workbook, you also have to create/destroy the menu when those sheets are Activated/Deactivated. When I do it, I just set up a call to an "AddMenu" or a "ResetMenu" routine so that I only have to write those routines once. Contact me via eMail (remove spaces) at HelpFrom @ jlathamsite.com and I'll send you a workbook that has demo code to show how I get it done - you can examine the code and adapt it to your needs? "Luis" wrote: Can someone help me with the "How to" trigger a VBA code to set up a menu if a particular workbook is opened? The reason that I need this code is that I have a workbook that is generate every week and would like to be able to generate a custom menu that every time that this particular workbook is open is generate a custom menu. The only way that I can do this is by adding the vba code in ThisWorkbook but because it is generate everytime the code is override. Suggestions please. Luis |
Help - VBA Code execution in Excel
I should add that you can find a lot of info, including code examples, he
http://www.ozgrid.com/VBA/custom-menus.htm and Microsoft has a boatload of info he http://support.microsoft.com/default...&\1Product=xlw "JLatham" wrote: Louis, Properly controlling a custom menu is rather complex. You need to set things up to create the menu when the workbook is Opened or Activated, and the menu must be destroyed when the workbook is Closed or Deactivated. If the menu is to be associated only with certain worksheets in the workbook, you also have to create/destroy the menu when those sheets are Activated/Deactivated. When I do it, I just set up a call to an "AddMenu" or a "ResetMenu" routine so that I only have to write those routines once. Contact me via eMail (remove spaces) at HelpFrom @ jlathamsite.com and I'll send you a workbook that has demo code to show how I get it done - you can examine the code and adapt it to your needs? "Luis" wrote: Can someone help me with the "How to" trigger a VBA code to set up a menu if a particular workbook is opened? The reason that I need this code is that I have a workbook that is generate every week and would like to be able to generate a custom menu that every time that this particular workbook is open is generate a custom menu. The only way that I can do this is by adding the vba code in ThisWorkbook but because it is generate everytime the code is override. Suggestions please. Luis |
All times are GMT +1. The time now is 10:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com