Add-in must be 'run' one time to stick? How to auto invoke?

Thanks to Dave Peterson's recent sample and tips to get started I have
gotten past the notion of a script-holding template file and
gotten all the functionality I need into a .xla addin menu

The functions in the addin are made available thru a toolbar
menu created like...

Set cbcCutomMenu = _
      cbMainMenuBar.Controls.Add(Type:=msoControlPopup, _
                   Before:=iHelpMenu)

      '(5)Give the control a caption
      cbcCutomMenu.Caption = "M&y Menu"

....

and added by these subs in the 'View Code' thingy:

Private Sub Workbook_Activate()
Run "AddMenus"
End Sub

Private Sub Workbook_Deactivate()
Run "DeleteMenu"
End Sub

Now, the sources I found indicate the menu should appear
once the Add-in has been loaded. It doesn't....I seem forced to
Run the AddMenus sub one time. After that, the menu is available
in subsequent Excel sessions. Is there a way to avoid that one-time run?

TIA - Lynn.


0
lynn5514 (10)
12/27/2005 12:01:50 AM
excel 39879 articles. 2 followers. Follow

4 Replies
312 Views

Similar Articles

[PageSpeed] 20

Make sure the Workbook_activate and workbook_deactivate are both under the
ThisWorkbook module (not under a worksheet.

And since your Addmenus and DeleteMenu routines are in General modules of the
same workbook's project, you can just call then (instead of using Run).

Private Sub Workbook_Activate()
  Call AddMenus
End Sub

Private Sub Workbook_Deactivate()
  Call DeleteMenu
End Sub

(The Call statement isn't required--but I like it (other's don't).)



Lyndon Rickards wrote:
> 
> Thanks to Dave Peterson's recent sample and tips to get started I have
> gotten past the notion of a script-holding template file and
> gotten all the functionality I need into a .xla addin menu
> 
> The functions in the addin are made available thru a toolbar
> menu created like...
> 
> Set cbcCutomMenu = _
>       cbMainMenuBar.Controls.Add(Type:=msoControlPopup, _
>                    Before:=iHelpMenu)
> 
>       '(5)Give the control a caption
>       cbcCutomMenu.Caption = "M&y Menu"
> 
> ...
> 
> and added by these subs in the 'View Code' thingy:
> 
> Private Sub Workbook_Activate()
> Run "AddMenus"
> End Sub
> 
> Private Sub Workbook_Deactivate()
> Run "DeleteMenu"
> End Sub
> 
> Now, the sources I found indicate the menu should appear
> once the Add-in has been loaded. It doesn't....I seem forced to
> Run the AddMenus sub one time. After that, the menu is available
> in subsequent Excel sessions. Is there a way to avoid that one-time run?
> 
> TIA - Lynn.

-- 

Dave Peterson
0
petersod (12004)
12/27/2005 12:16:04 AM
Thanks again Dave, now I got it. Next question - Since the 
Activate...Deactivate subs must be in ThisWorkbook, is there a method 
available to insert them programmaticaly.

Guess I'm looking for an OLE method here, to do the job from outside of 
Excel.

It seems the M$ method is M3 on the excel icon next to File menu, See 
Code' and type in the subs. I really don't want to have my users do that 
if at all avoidable...

  - Lynn.



Dave Peterson wrote:
> Make sure the Workbook_activate and workbook_deactivate are both under the
> ThisWorkbook module (not under a worksheet.
> 
> And since your Addmenus and DeleteMenu routines are in General modules of the
> same workbook's project, you can just call then (instead of using Run).
> 
> Private Sub Workbook_Activate()
>   Call AddMenus
> End Sub
> 
> Private Sub Workbook_Deactivate()
>   Call DeleteMenu
> End Sub
> 
> (The Call statement isn't required--but I like it (other's don't).)
> 
> 
> 
> Lyndon Rickards wrote:
> 
>>Thanks to Dave Peterson's recent sample and tips to get started I have
>>gotten past the notion of a script-holding template file and
>>gotten all the functionality I need into a .xla addin menu
>>
>>The functions in the addin are made available thru a toolbar
>>menu created like...
>>
>>Set cbcCutomMenu = _
>>      cbMainMenuBar.Controls.Add(Type:=msoControlPopup, _
>>                   Before:=iHelpMenu)
>>
>>      '(5)Give the control a caption
>>      cbcCutomMenu.Caption = "M&y Menu"
>>
>>...
>>
>>and added by these subs in the 'View Code' thingy:
>>
>>Private Sub Workbook_Activate()
>>Run "AddMenus"
>>End Sub
>>
>>Private Sub Workbook_Deactivate()
>>Run "DeleteMenu"
>>End Sub
>>
>>Now, the sources I found indicate the menu should appear
>>once the Add-in has been loaded. It doesn't....I seem forced to
>>Run the AddMenus sub one time. After that, the menu is available
>>in subsequent Excel sessions. Is there a way to avoid that one-time run?
>>
>>TIA - Lynn.
> 
> 
0
lynn5514 (10)
12/29/2005 3:26:09 AM
I would think that it would be much easier to create the code while you're
creating the workbook.

But Chip Pearson has some notes that will show you how to write code that writes
code:

http://www.cpearson.com/excel/vbe.htm




Lyndon Rickards wrote:
> 
> Thanks again Dave, now I got it. Next question - Since the
> Activate...Deactivate subs must be in ThisWorkbook, is there a method
> available to insert them programmaticaly.
> 
> Guess I'm looking for an OLE method here, to do the job from outside of
> Excel.
> 
> It seems the M$ method is M3 on the excel icon next to File menu, See
> Code' and type in the subs. I really don't want to have my users do that
> if at all avoidable...
> 
>   - Lynn.
> 
> Dave Peterson wrote:
> > Make sure the Workbook_activate and workbook_deactivate are both under the
> > ThisWorkbook module (not under a worksheet.
> >
> > And since your Addmenus and DeleteMenu routines are in General modules of the
> > same workbook's project, you can just call then (instead of using Run).
> >
> > Private Sub Workbook_Activate()
> >   Call AddMenus
> > End Sub
> >
> > Private Sub Workbook_Deactivate()
> >   Call DeleteMenu
> > End Sub
> >
> > (The Call statement isn't required--but I like it (other's don't).)
> >
> >
> >
> > Lyndon Rickards wrote:
> >
> >>Thanks to Dave Peterson's recent sample and tips to get started I have
> >>gotten past the notion of a script-holding template file and
> >>gotten all the functionality I need into a .xla addin menu
> >>
> >>The functions in the addin are made available thru a toolbar
> >>menu created like...
> >>
> >>Set cbcCutomMenu = _
> >>      cbMainMenuBar.Controls.Add(Type:=msoControlPopup, _
> >>                   Before:=iHelpMenu)
> >>
> >>      '(5)Give the control a caption
> >>      cbcCutomMenu.Caption = "M&y Menu"
> >>
> >>...
> >>
> >>and added by these subs in the 'View Code' thingy:
> >>
> >>Private Sub Workbook_Activate()
> >>Run "AddMenus"
> >>End Sub
> >>
> >>Private Sub Workbook_Deactivate()
> >>Run "DeleteMenu"
> >>End Sub
> >>
> >>Now, the sources I found indicate the menu should appear
> >>once the Add-in has been loaded. It doesn't....I seem forced to
> >>Run the AddMenus sub one time. After that, the menu is available
> >>in subsequent Excel sessions. Is there a way to avoid that one-time run?
> >>
> >>TIA - Lynn.
> >
> >

-- 

Dave Peterson
0
petersod (12004)
12/29/2005 12:17:59 PM
Final thanks to Dave for the guidance and references. The Chip Pearson
page finally set me right, and FWIW I wound up using plain 'ole perl
to achieve the design spec.

To avoid irrelevant xposting, working example is over on..

http://aspn.activestate.com/ASPN/Mail/Message/perl-win32-users/2960933

Thanks - Lynn.


Dave Peterson wrote:
> I would think that it would be much easier to create the code while you're
> creating the workbook.
>
> But Chip Pearson has some notes that will show you how to write code that writes
> code:
> 
> http://www.cpearson.com/excel/vbe.htm
> 
> 
<--snip->

0
lynn5514 (10)
1/2/2006 4:40:51 PM
Reply:

Similar Artilces:

Run time error
Can some kind person explain why this code produces Run time Error 1004 LastRow = .Cells(.Rows.count, "A").End(x1Up).row -- jee22@msm.cam.ac.uk Materials Science & Metallurgy Ext 34346 sorry I should have included all the code as follows Dim c, n, row, e, col As Integer Dim LastRow As Long Dim t, celladdr As String Dim wks As Worksheet Set wks = ActiveSheet With wks LastRow = .Cells(.Rows.count, "A").End(xlUp).row End With It is the LastRow = that is generating the error Thanks "jee22" <jee22@msm.cam.ac.uk> wrote in message news:cd5he6$qpt$1@pe...

How do I move an Exchange mailbox from one user to another?
I'm new to Exchange and my first task proved to be a bit more than I could chew: One of my users, lets call her Annie, has two NT accounts in my domain: AnnieA and AnnieB. AnnieA has email address AnnieA@MyDomain.com and AnnieB doesn't have email. Now I want to remove account AnnieA and let AnnieB inherit AnnieA's email address and mail box. How do I do this? Thanks! /Carl What version of Exchange? In 5.5 you can just go to the mailbox properties and change the user account associated with the mailbox. In 2000 you use ADU&C to right click >exchange tasks >remove mai...

Excel Add Ins
What is the name of the template wizard with Data Tracking (Excel. I can not locate the add in template wizard with Data Tracking in Office 2003 Hi Richard You are not the only one<g> The Add-in is working in 2003 only the install file is not working. Copy the xla file from a PC with 2002 to the PC with 2003 and it will work(use Tools>add-ins to browse to the file in Excel) -- Regards Ron de Bruin http://www.rondebruin.nl "Richard" <Richard@discussions.microsoft.com> wrote in message news:193C5DFD-578D-48F7-B9D6-9FEF5BDCEB64@microsoft.com... > What is t...

log file of email open time/date
Hi, I needed to know if there is a way to keep a log file or to view information about when the emails I receive are opened. I probably needed information like date and time. I am the person opening the emails but I needed to show someone when I opened them. Emails are coming from various different people using different email software, so it can't be tracked from their end. I have Outlook 2000, but might need to use it in different versions of Outlook. so if you know of a feature that I can use, can you also tell me if it's available for different versions? thanks a lot. I apprec...

Add Lookup Fields to Entity
I need to add 4 "technical contact" fields (which would lookup the Contact entity) to the CONTRACT form. Is this possible? I've found it difficult to figure out what to do first. Thanks in advance, Brandon Not possible. You cant have multiple lookups for the same entity. You also cannot create new relationships between two system entitites. This will work in 4.0 Not possible, Pezman. N:M relationships are not possible in 3.0 yet. There is a alternative solution: a new entity to act as an N:M relationship. In your case, Contract/Contact. This entity has two 1:N relations...

Run macro via cell value
Is it possible to run a macro based on the value of a cell. Say for example A1 contains the word "run" can that word be the trigger to automatically run a macro? Pat Hi Pat A worksheet formula can not trig a macro. No way. But a worksheet has several events; macros that run when certain things happen. There is an event firing when you enter something into a cell, another when the sheet recalculates, ... see http://www.cpearson.com/excel/events.htm for more on this. HTH. Best wishes Harald "Pat" <glass_patrick@hotmail.com> skrev i melding news:OV4A5QBUFHA.58...

Add on
Hello, Here is a scenerio. A client is buying 1lb of ham. It is put on a waxed paper then wrapped into a white paper and then put into a shopping bag. The usage of shopping bag is 100% cases the usage of paper is only with certin categories of sales. Same with the waxed paper. Question: Is there a way of associating wax paper, white paper and shopping bags in a way so with every sale a piece of paper gets deducted from inventory and one bag is deducted from inventory? I would like to run a report every so often and see if I need to purchase any supplies. Kits and assembly do not work...

add a row or column to a single cell in exel
I am trying to split a single cell into 2 rows can you help If I understood correctly you want to enter an entry in two lines in a cell at appropirate place hit lt+enter and again hit enter for e.g venkat (alt+enter) raman(enter) "trev" <trev@discussions.microsoft.com> wrote in message news:89B2C15C-057F-43B9-8282-37923D5EA397@microsoft.com... > I am trying to split a single cell into 2 rows can you help ...

way to delete add. fr. auto. email add. function?
Is there a way to delete old or no longer used email addresses that appear in the drop down box when I am addressing a new email? Shebubba wrote: > Is there a way to delete old or no longer used email addresses that appear in > the drop down box when I am addressing a new email? That is the nickname cache. Search and delete the .nk2 file. That's the cache for nicknames (i.e., your manually entered e-mail addresses). If you only want to delete some of them, highlight an entry and hit the delete key. If that doesn't work, use Nirsoft's NK2 Viewer utility (it e...

POS 2009 Add-In: Populating a Task Pad
I would like to create a custom application that has the ability to maintain the items that are on certain Task Pads within POS 2009. These items would all be regular menu items (ex: hamburger, hot dog, french fries, etc) and not functions. For example, if a task pad was supposed to allow the cashier quick access to daily specials, then this custom application would need to be able to clear the task pad each day and add the items for that day. Is this going to be possible? Please provide some guidance. Thank you, Sean This is a multi-part message in MIME format. ------=_NextPart_00...

Add-in cannot be loaded OL07
Every time I open Outlook 2007 I get an error message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). It says the add-in cannot be loaded and has been disabled by Outlook. I've been getting this message ever since I uninstalled Winfax. How do I make this error stop appearing? Thanks. -- kapibarra Remove the addin from OL by using Trust Center, Addins. http://office.microsoft.com/en-us/outlook/HA100341271033.aspx#14 "kapibarra" wrote: > Every time I open Outlook 2007 I get an error > message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). ...

Format text to add character
I have two fields that should match, but one includes special characters while the other does not. Example: Field1 00ABCD123456123 Filed2 00/ABCD/123456/123/SBZ I need to find records where these two fields don't match, either by changing the display of one of them, or a query to compare Field1 character 7-15 with Field2 characters 9-14, 16-18. Hope this makes sense. Can anyone help? Thanks! Take a look at the following from the Access Help file it might be what you're looking for... Extract a part of a text value The following table lists examples of expressions that ...

Multiple accounts with one bank/broker
I have several accounts with one bank but they have different passwords (accounts are under different SSNs). In Money 2007, I can only figure out how to setup one password per bank/broker in the "manage online services". Can someone tell me if its possible to automatically download transactions from one institution for four accounts with four different log in identifications? DougKC, You CAN set up separate online accounts with different passwords from the same broker. I've successfully done it with Fidelity. However, you can't "manage online services" tha...

Add File menu to custom toolbar
Hi All, I am trying to add the 'File" menu and "Window" menu of the Standard Toolbar to a custom toolbar but failing miserably! I think it should look something like: Sub AddMenuTitles() Application.CommandBars("MyCustomMenu").Controls.Add("File) Application.CommandBars("MyCustomMenu").Controls.Add("Window") End Sub Can anybody help please Regards Michael Sub test() AddMenuTitles True ' or false to delete End Sub Sub AddMenuTitles(bAdd As Boolean) Dim cbr As CommandBar Dim cbP As CommandBarPopup ...

two sql tranform statement on one report
How do i get two tranforms statement on the same report but the pivot part to only be used like below Tranform Select From Where Group By Pivot in (1,3,5,7) then another on same report Tranform Select From Where Group By Pivot in (2,4,6,8) any ideas??? One way I can think of is to use sub-reports. The other option would be to use a union query to combine the two crosstab queries if the queries were returning the same basic data. And then group by the "source" SELECT "A" as Source, FldA, FldB , [1] as A, [3] as B, [5] as C, [7...

Crystal Reports Running Slow
Is there any general reasons why Crystal Reports could all-of-a-sudden be running significantly slower than it has in the past? Thanks, Boolean1 ...

add a DC in a LegSite
Hi, In the disaster recovery plan we want to create a leg site and put a DC in it. Here are some questions on how to achieve this smoothly. 1. Should I create the new site/subnet first and then promote a server in that subnet/site to DC, or should I promote a server in existing site/subnet and then move this DC to the new site/subnet? 2. When promoting a server to DC, should the server be a member server (already joined the domain) or just a workgroup member (no domain membership)? 3. The DC will be an AD-integrated DNS server. Should I install the DNS component (but not confi...

Dateserial same every time
I don't know what I am doing wrong but I am using DateSerial as a default in a textbox and no matter what I keep getting 1/31/2010. I have tried to put in anything just to get it to be something other than 1/31/2010...DateSerial(Year(Date()),Month(Date()),0) AND DateSerial(Year (DateField), Month(DateField)+1,0) AND even tried to hard code DateSerial (2005,12,12)...still got 1/31/2010! What I doing something wrong? Thanks in advance... -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201002/1 I can understand why you...

How can I add the customer's PO# to the drop-ship Purchase Order?
Our purchasing agent would like to be able to have the customers PO# from the Sales Transaction Entry screen show up on the PO's. Is this doable in Report Writer or can it not be done? We are using GP v9.0. As I still consider myself a newbie with RW, I would appreciate detailed instructions if possible. Thank you in advance for all responses. It is not possible thru traditional table relationships in Report Writer. Let me explain: you can certainly link the Purchase Order Work table to the SOP_POLink table and the SOP_POLink table to the SOP Transactions Work table, but will...

excel add-ons
Awhile back, there was an add-on for excel that had a lot more tools. It showed on the toolbar. Somehow I lost it and I would like to get it back. It had a lot of tools like for changing case and fill ins. Any help wouyld be great. Maybe ASAP Utilities. Try a 'net search for this add-in. Gord Dibben MS Excel MVP On Sun, 22 Mar 2009 20:22:43 -0400, "kmkx70a" <kmkx70a@prodigy.net> wrote: >Awhile back, there was an add-on for excel that had a lot more tools. It >showed on the toolbar. Somehow I lost it and I would like to get it back. It >had a lot of t...

Having OL automatically add a bcc: address
My boss wants to add me as a bcc: to every email she sends. Is there a way to set this up to happen automatically? Please reply to matt@lkigroup.com Thanks much. Matt ...

Map Add-On?
I am looking for an Excel Chart add on so that I can take numerical data and display it on a geographic map of states or zip codes for example. Even better I could color or shade a state based on the values in my spreadsheet. Any suggestions would be appreciated. Mark ...

How to add a VScroll to a CStatic Object
I create a CStatic object and write some text to the object but the text is too long to display in the work area but I don't konw how to add a vscroll to a CStatic object who can help me? I would say instead of a CStatic, use a CEdit control with the ReadOnly flag set. Because static controls by default aren't scrollable, so even if you add a scrollbar to it, you will have to manage the entire thing yourself (drawing, scrolling....), more trouble than it's worth. Ali R. "Smallfrogs" <super_smallfrogs@hotmail.com> wrote in message news:eLAO92y7DHA.2832@tk2msft...

Add ContractLine Entity in Menu
Hi, Is it possible to add a shortcut in the Service Menu to the ContractLine Entity? I really appreciate if someone could help. Regards, Alcides ...

Issue with one account's password...
I've been beating my head against the wall on this one for awhile now... I have one user who's password will not work. I've tried resetting it numerous times, and it will still not allow her or myself to log in. What could I be missing here? Keep in mind that I'm pretty new to this Exchange Server stuff in any replies you may have. Thanks so much for any help you can throw my way! By the way, the password is very simple, so it's not an issue of mis-typing. Also, I've given it plenty of time to update the AD listing, so that shouldn't be an issue, right?...