#1   Report Post  
ditchy
 
Posts: n/a
Default on exit macro

Hello there
would someone be able to help me with a way to reinstate Toolbars
on exit.
The problem I have at the moment is when I remove the toolbars and
close, the toolbars are gone from all workbooks. I need the toolbars to
be unhidden on exit.
Macro below, help would be appreciated
Thanks Ditchy


Option Base 1
Public VisibleState(200) As Variant



Sub RemoveToolbars()
Dim a As Integer:
Application.CommandBars("Worksheet Menu Bar").Enabled = False
For a = 1 To Application.CommandBars.Count
VisibleState(a) = Application.CommandBars(a).Visible
If CommandBars(a).Visible = True Then CommandBars(a).Visible = False
Next a
End Sub





Sub ReinstateToolbars()
Dim a As Integer
Application.CommandBars("Worksheet Menu Bar").Enabled = True
On Error Resume Next
For a = 1 To Application.CommandBars.Count
Application.CommandBars(a).Visible = VisibleState(a)
Next a
End Sub

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

I have modified your routine as well

Option Explicit

Option Base 1
Public VisibleState()

Sub RemoveToolbars()
Dim a As Long
Dim cCBs As Long
Application.CommandBars("Worksheet Menu Bar").Enabled = False
ReDim VisibleState(1)
cCBs = 1
For a = 1 To Application.CommandBars.Count
If CommandBars(a).Visible = True Then
ReDim Preserve VisibleState(cCBs)
VisibleState(cCBs) = Application.CommandBars(a).Name
CommandBars(a).Visible = False
cCBs = cCBs + 1
End If
Next a
End Sub

Sub AddToolbars()
Dim a As Integer:
Application.CommandBars("Worksheet Menu Bar").Enabled = True
For a = LBound(VisibleState) To UBound(VisibleState)
Application.CommandBars(VisibleState(a)).Visible = True
Next a
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"ditchy" wrote in message
oups.com...
Hello there
would someone be able to help me with a way to reinstate Toolbars
on exit.
The problem I have at the moment is when I remove the toolbars and
close, the toolbars are gone from all workbooks. I need the toolbars to
be unhidden on exit.
Macro below, help would be appreciated
Thanks Ditchy


Option Base 1
Public VisibleState(200) As Variant



Sub RemoveToolbars()
Dim a As Integer:
Application.CommandBars("Worksheet Menu Bar").Enabled = False
For a = 1 To Application.CommandBars.Count
VisibleState(a) = Application.CommandBars(a).Visible
If CommandBars(a).Visible = True Then CommandBars(a).Visible = False
Next a
End Sub





Sub ReinstateToolbars()
Dim a As Integer
Application.CommandBars("Worksheet Menu Bar").Enabled = True
On Error Resume Next
For a = 1 To Application.CommandBars.Count
Application.CommandBars(a).Visible = VisibleState(a)
Next a
End Sub



  #3   Report Post  
ditchy
 
Posts: n/a
Default

thank you again BoB
where would we be without the generous help that you all provide, much
appreciated
regards, Ditchy

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
automatic macro update boconnell Excel Worksheet Functions 4 February 9th 05 07:10 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"