Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2004, 07:40 AM
Authorized User
 
Join Date: Jul 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default How To avoid the SAving of toolbars while saving

I have created a custom tool bar for a active work book in excel.
I have to save the excel file but the toolbar created must not be saved.But the toolbar should be present till the workbook is closed.

How to achieve this?

Hari
 
Old July 15th, 2004, 11:48 AM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
 As I haven't seen your code, I do not know how you created it. But to let it be visible until you close the workbook, you should delete it in the.
Workbook_BeforeClose event. So in the module 'ThisWorkbook'
you do something like this.

eg.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call RemoveCustomMenu
End Sub

And in a normal module place something like this.

Public Sub RemoveCustomMenu()
   Dim cbWSMenuBar As CommandBar

   On Error Resume Next
   Set cbWSMenuBar = CommandBars("Worksheet Menu Bar")
   cbWSMenuBar.Controls("MyMenu").Delete
End Sub

Hope it helped.
Cheers
Karsten



 
Old July 16th, 2004, 03:48 AM
Authorized User
 
Join Date: Jul 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But this will promt me to save the workbook as the toolbar is deleted.



 
Old July 16th, 2004, 05:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you don't want to save anything in the workbook add the line
Code:
thisworkbook.saved True
to the Workbook_BeforeClose event. This tricks Excel into believing that there have been no changes since the last save.

Chris

There are two secrets to success in this world:
1. Never tell everything you know
 
Old July 19th, 2004, 03:46 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could also try:

Code:
Sub createMyToolbar()
  With Application.CommandBars.Add(Name:="My Temporary Toolbar", Temporary:=True)
    With .Controls.Add(Type:=msoControlButton, Temporary:=True)
      .Caption = "My Temporary Button"
      .OnAction = "MyOnActionProperty"
    End With
  End With
End Sub
In other words, create the toolbar/button(s) using the Temporary parameter.

You could place this code in a global XLA (Excel Addin) file to be copied into your XLSTART folder.

You'd probably then want to launch this code from something like an AutoExec procedure within the global addin.
 
Old July 19th, 2004, 11:08 PM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
If you want to save without being promted, you can put the following in the
Workbook_BeforeClose event.

If Not ThisWorkbook.Saved Then
   ThisWorkbook.Save
End If

Cheers
Karsten


 
Old July 26th, 2004, 12:13 AM
Authorized User
 
Join Date: Jul 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lot






Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL question saving a file saving the the first macupryk VS.NET 2002/2003 0 January 6th, 2005 05:33 PM
Regarding saving the document Hari_Word Excel VBA 1 October 29th, 2004 10:49 AM
Saving davidhowell1971 Excel VBA 1 March 1st, 2004 04:02 PM
Saving to the clipboard xelepi Javascript How-To 2 November 7th, 2003 07:51 AM
Saving settings...!? jacob VS.NET 2002/2003 1 October 15th, 2003 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.