I have several Excel workbooks that have custom Tool Bars.
In Excel 2010, they decided that custom toolbars need to be in "Add-Ins", 
which, in my opinion, was a poor decision.
 
What I use is:
 
I created a macro called New_CmdBar
in which I define the toolbar (called "PMTR").
 
Then, in the ThisWorkbook module:
 
Private Sub Workbook_Activate()
    Dim  stat
    on Error Resume Next
    Application.CommandBars("PMTR").Enabled = True
    if (Err.Number <> 0) then stat = New_CmdBar(False) 
    Application.CommandBars("PMTR").Visible = True      
    Application.CommandBars("Ribbon").Enabled = True   
    On Error Goto 0
End Sub
Private Sub Workbook_Deactivate()
    Application.CommandBars("PMTR").Enabled = False
    Application.CommandBars("PMTR").Visible = False
End Sub

I also have:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
         Application.CommandBars("PMTR").Delete
End Sub


So basically, whenever the workbook is opened, it creates the new Toolbar.
When you select a different workbook, it "hides" the toolbar.
When you re-activate the workbook, it displays the toolbar, or re-creates it if 
necessary.
Exiting the workbook causes the toolbar to be deleted.

The only issue with this that I've had is if I have two copies of the workbook 
open.
Closing one deletes the toolbar.  But I just have to minimize and maximize the 
workbook to get it back.
Paul
-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------


>________________________________
> From: "dwbowye...@gmail.com" <dwbowye...@gmail.com>
>To: excel-macros@googlegroups.com 
>Cc: cdr...@gmail.com 
>Sent: Friday, March 7, 2014 3:09 AM
>Subject: Re: $$Excel-Macros$$ Link Custom Toolbar with a file
>  
>
>
>Thanks Clive but iy didn't help. 
>What I guess I'm looking for is an event that is triggered when a programme is 
>brought back to the full page state from the diminished state on the Task Bar. 
>donwb
> 
>
>
>On Tuesday, 4 March 2014 18:40:43 UTC, clive r wrote: 
>You could MAYBE try "RECORD MACRO"  to manually invoke the toolbar,  
>>then look at the auto-generated code for clues. 
>>
>>
>>
>>On 4 March 2014 18:19, <dwbow...@gmail.com> wrote:
>>
>>I am using Excel 2003 on Windows 7 Pro 64 bit 
>>>  
>>>When I open a file I need to call up an associated Custom Toolbar. 
>>>I have written VBA modules to do this and they work OK. 
>>>However when I reduce the application to the TaskBar (pressing"_"), 
>>>then retrieve it by clicking it's Icon on the TaskBar, it opens OK, but 
>>>without the toolbar. 
>>>The code below is in place:- 
>>>  
>>>Sub Auto_Open() 
>>>Application.ScreenUpdating = False 
>>>Application.EnableEvents = False 
>>>Application.CommandBars(" MyToolbar").Visible = True 
>>>More code……… 
>>>  
>>>And under "This Workbook":- 
>>>Private Sub Workbook_Activate() 
>>>Application.ScreenUpdating = False 
>>>Application.CommandBars(" MyToolbar").Visible = True 
>>>On Error GoTo Line1 
>>>Workbooks("Book1.xls").Close savechanges:=False 
>>>Line1: 
>>>End Sub 
>>>  
>>>Private Sub Workbook_Deactivate() 
>>>Application.ScreenUpdating = False 
>>>On Error GoTo Line1 
>>>Application.WindowState = xlMinimised 
>>>Line1: 
>>>End Sub 
>>>  
>>>Private Sub MyShutdown() 
>>>Application.ScreenUpdating = False 
>>>UserForm4.Show 
>>>End Sub 
>>>  
>>>Private Sub Workbook_Open() 
>>>Application.CommandBars(" MyToolbar").Visible = True 
>>>End Sub 
>>>  
>>>Private Sub Workbook_SheetActivate(ByVal Sh As Object) 
>>>Application.CommandBars(" MyToolbar").Visible = True 
>>>Call Load 
>>>End Sub 
>>>  
>>>Private Sub Workbook_WindowActivate(ByVal Wn As Window) 
>>>Application.ScreenUpdating = False 
>>>Application.CommandBars(" MyToolbar").Visible = True 
>>>LS = Worksheets("CBs").Range(" MyLastSheet").Value 
>>>Application.Worksheets(LS). Select 
>>>Line1: 
>>>End Sub 
>>>  
>>>Private Sub Workbook_WindowDeactivate( ByVal Wn As Window) 
>>>Application.CommandBars(" MyToolbar").Visible = False 
>>>End Sub 
>>> but none of this activates the toolbar. 
>>>Help please 
>>>donwb
-- 
>>>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>>>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>>>https://www.facebook.com/discussexcel
>>> 
>>>FORUM RULES
>>> 
>>>1) Use concise, accurate thread titles. Poor thread titles, like Please 
>>>Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will 
>>>not get quick attention or may not be answered.
>>>2) Don't post a question in the thread of another member.
>>>3) Don't post questions regarding breaking or bypassing any security measure.
>>>4) Acknowledge the responses you receive, good or bad.
>>>5) Jobs posting is not allowed.
>>>6) Sharing copyrighted material and their links is not allowed.
>>> 
>>>NOTE : Don't ever post confidential data in a workbook. Forum owners and 
>>>members are not responsible for any loss.
>>>--- 
>>>You received this message because you are subscribed to the Google Groups 
>>>"MS EXCEL AND VBA MACROS" group.
>>>To unsubscribe from this group and stop receiving emails from it, send an 
>>>email to excel-macros...@ googlegroups.com.
>>>To post to this group, send email to excel-...@googlegroups.com.
>>>Visit this group at http://groups.google.com/group/excel-macros.
>>>For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
-- 
>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
>2) Don't post a question in the thread of another member.
>3) Don't post questions regarding breaking or bypassing any security measure.
>4) Acknowledge the responses you receive, good or bad.
>5) Jobs posting is not allowed.
>6) Sharing copyrighted material and their links is not allowed.
> 
>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to excel-macros+unsubscr...@googlegroups.com.
>To post to this group, send email to excel-macros@googlegroups.com.
>Visit this group at http://groups.google.com/group/excel-macros.
>For more options, visit https://groups.google.com/d/optout.
>
>
>    

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to