Home > Excel Vba > Workbook_beforesave Not Working

Workbook_beforesave Not Working


What is the most someone can lose the popular vote by but still win the electoral college? The sheet is not protected, and if you try to unprotect a protected worksheet, that does not work either. However, is there a work around to allow a macro to save? ---------------------------------------------------------------------- Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) 'this disables the save function on the XLS MsgBox Here is the very simple code as it stands Private Sub Workbook_BeforeClose(Cancel As Boolean) Cancel = True frmCloseSplash.Show End Sub So I'm calling a userform that I've created in which the Source

See also Concepts Workbook Object Other resources Workbook Object Members Show: Inherited Protected Print Export (0) Print Export (0) Share IN THIS ARTICLE Is this page helpful? Guide to Making Your Macro Run Faster and Better in Excel This guide will show you 4 different ways to make your macros run faster and more efficiently in Excel. I > > have > > > > two problems:- > > > > > > > > 1) My code causes excel to crash > > > > 2) The I am resisting the urge to upload my code because it is fairly large.

Workbook_beforesave Not Working

Remember Me? Its like the code is fine but the repainting/refreshing of the screen isn't... Should I report it?

  1. In the BeforeSave event : no problem.
  2. this is a good de-bug tool.
  3. There are my Sub in addin: Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _ ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "Good bye!
  4. The Macro works perfectly if I save it to a button and don't use a save event to trigger it, but I just don't understand enough about the event to fix
  5. Steve Monday, January 09, 2012 12:36 PM Reply | Quote 0 Sign in to vote Steve, Glad you got it working and thanks for the feedback.
  6. The user then has two options on the user form "Save" and "Close." If the user clicks save the code takes the user through the getsaveasfilename procedure, saves the file, and
  7. Privacy statement Community Resources O365 Technical Network MSDN Forums UserVoice Stack Overflow Follow Us Twitter Facebook Office Dev Blog © 2016 Microsoft United States - English Terms of Use Trademarks Privacy
  8. I agree with your take on what's going on though a couple of things I'd have put slightly differently, but that's splitting hairs!
  9. Private Sub Workbook_BeforeClose(Cancel As Boolean) If ActiveWorkbook.Saved = True Then Cancel = False Else Dim iReply As Byte, iType As Integer Dim events As Boolean Dim alerts As Boolean events =

Thanks in advance!!! Code: If SaveAsUI = False Then Cancel = True MsgBox "You cannot save this workbook. Thank you, Gos-C Ask Your Own Question Disable Saving In Beforeclose Event - Excel Excel Forum Hi, Got my template XLT and I don't want my user to save any Spreadsheet Workbook_beforesave Example Teenage daughter refusing to go to school Atmega328P 8MHz External Clock Build me a brick wall!

Early vs Earlier What does a white over red VASI indicate? Excel Vba Run Macro On Save Please see this link for a better explanation of using application level events. The problem being that the BeforeClose event fires before it asks if they wish to save, so I can't use the BeforeClose event to cancel the close if the save fails. Browse other questions tagged excel vba xlsm or ask your own question.

Use Save As" End If End Sub The macros I use to save the book are called Macro1 and Macro2 Kind Regards, Dan. Excel Vba Beforesave Do you" & _ vbCrLf & "want to overwrite it?", _ vbCritical + vbYesNo, _ vbNullString) [color=darkblue]Case[/color] vbYes [color=green] '// User selected , so kill alerts, overwrite, then do the //[/color] Some other application events of use are: App_SheetActivate App_WorkbookActivate App_WorkbookOpen App_WorkbookBeforeClose App_WorkbookBeforeSave Here's a list of all events, but note that some of them are workbook (event handlers start with Workbook_ In all my searches I have never seen the succinct explanation you posted here: "Don't set the Cancel flag in the BeforeSave event handler if the workbook (being saved) is in

Excel Vba Run Macro On Save

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices. Something like this: Dim lAnswer As Long Dim szMsg As String ''''' Other code here szMsg = "Choose one of the following:" & vbLf & _ "Yes = Save as workbook" Workbook_beforesave Not Working All the user would have to do is right click the menu select a toolbar such as 'standard' and the all the menus reappear. Workbook_beforesave Saveasui Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

You really should incorporate some sort of error trapping or other code to accommodate for that issue. this contact form Are there stats for Mihstu in 3.5e? Share Share this post on Digg Technorati Twitter Reply With Quote May 22nd, 2002,08:31 PM #9 Tom Schreiner Board Regular Join Date Mar 2002 Location Cincinnati, Ohio, USA Posts 6,824 I wanted to force this macro to run every time the user clicks save so I used a Workbook_BeforeSave event. Private Sub Workbook_beforesave

If Not Me.Saved Then Dim msg As String msg = "Do you want to save the changes you made to " msg = msg & Me.Name & i.e only the worksheet menu bar will be visible. If I start with a new document and insert the some code against the beforesave event so that it automatically adds the .xls onto the name of the file being saved. have a peek here To save a copy, click OK, then give the workbook a new name in the Save As dialog box." How can I get it react the same way to the Save

asked 4 years ago viewed 2773 times active 4 years ago Upcoming Events 2016 Community Moderator Election ends in 9 days Related 18excel vba call subroutine with variables0excel vba subroutine call Excel Vba Run Macro Before Save After that date, they must have something in that cell before they can save the workbook. I think that solves your second issue. –Maarten van Stam Jan 25 at 12:28 The other comments are actually new questions :-) Leaving the blank screen can be solved

You will be a Disables the "Save As" Feature in Excel - This macro will disable the Save As feature in excel.

Save is disabled. Members List Calendar Forum Rules Dashboard Commercial Services Advanced Search Forum Microsoft Office Application Help - Excel Help forum Excel Programming / VBA / Macros [SOLVED] BeforeSave Problem To get replies I have attached the file to assist and include the code below also: VB: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim strName As String On Error Goto InvalidName Excel Vba On Save Event It will search every worksheet in the workbook and return all of the mat Similar Topics Application.enable Events Problem - Excel Macro To Force Macros To Be Enabled And Prevent Saving

Quine Anagrams! (Cops' Thread) more hot questions question feed lang-vb about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / this is a good de-bug tool. > > regards > FSt1 > > "Andibevan" wrote: > > > How do you step through an event driven macro? > > > > Id apreciate some help in this matter, and i hope i made my self clear. You should also remember to set the Cancel flag in your BeforeSave handler if you have Saved the file programatically.

Stop Excel Events from Triggering when Running a Macro Create a macro that will run without triggering events, such as the Change event, or Activate event, or BeforeSave ... See our guidelines for contributing to VBA documentation. I am aware I could disable these to stop people selecting them in the first place but dont really want to go down this route as user may need to have Ask Your Own Question Private Sub Workbook_beforesave(byval Saveasui As Boolean, Cancel As Boolean) Problem - Excel Excel Forum I am trying to figure out why one code which works in a

There are many Close/Save combinations in Excel and it is hard to catch all the right combinations, so you might want to decide to handle it completely different ... If you close a WORKBOOK there is no extra questions -- just closes. If I change the line to what is below when the somebody uses the template it will keep creating more template files, rather than xls files. Do you wish to continue?" I am currently using the "Application.DisplayAlerts = False" code which I thought would stop the message box from appearing...

I have a BeforeSave event, that asks the user if they wish to save and continue, to save and exit, or to cancel. The time now is 11:42 AM. Will I get a visa again? then click the start macro icon.

I already tested it for your purposes and it works fine. share|improve this answer edited Sep 10 '12 at 18:56 answered Sep 5 '12 at 16:50 ak112358 4911825 add a comment| Your Answer draft saved draft discarded Sign up or log Thanks. Do you still want to save?", vbYesNo, "Entry Mandatory") If Response = vbNo Then Cancel = True Else Cancel = False With ActiveWorkbook 'Check if filename is equal to (B1_B2) If

Is this page helpful? You will need to capture this event at the application level. When I first was trying to use the kill command, it was crashing Excel I over came that by adding, Application.ScreenUpdating = False, and of course setting it back to True Copyright 2004 - VBA Express