Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 15th, 2004, 07:40 AM
Authorized User
 
Join Date: Jul 2004
Location: Chennai, Tamilnnadu, India.
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
Reply With Quote
  #2 (permalink)  
Old July 15th, 2004, 11:48 AM
Authorized User
 
Join Date: Feb 2004
Location: , , Denmark.
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



Reply With Quote
  #3 (permalink)  
Old July 16th, 2004, 03:48 AM
Authorized User
 
Join Date: Jul 2004
Location: Chennai, Tamilnnadu, India.
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.



Reply With Quote
  #4 (permalink)  
Old July 16th, 2004, 05:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
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
Reply With Quote
  #5 (permalink)  
Old July 19th, 2004, 03:46 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
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.
Reply With Quote
  #6 (permalink)  
Old July 19th, 2004, 11:08 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Denmark.
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


Reply With Quote
  #7 (permalink)  
Old July 26th, 2004, 12:13 AM
Authorized User
 
Join Date: Jul 2004
Location: Chennai, Tamilnnadu, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lot

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


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



All times are GMT -4. The time now is 07:14 PM.


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