Home > Excel Vba > Excel Vba Workbook_beforesave Not Working

Excel Vba Workbook_beforesave Not Working

Contents

It seems events are disabled by default. I have a function (saveMessage) asking if the user would like to save their work. Ive got this bit of code Code: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveAsUI Then MsgBox "The 'Save As' function has been disabled." Cancel = True End Excel Video Tutorials / Excel Dashboards Reports Reply With Quote January 18th, 2007 #2 Ranger View Profile View Forum Posts Long Term Member Join Date 25th January 2003 Location Scotland Posts this content

Then search for application.enableevents in the current project. If i did not cancel original save, each time a save was pressed a user would be sent back to the "open worksheet". Sorry it is a bit difficult to explain, but if you try and create an .xlt file with the code you originally gave me you will see the problem. What does a white over red VASI indicate?

Excel Vba Run Macro On Save

Code: Privatesub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean) Dim msg As String If Not Worksheets("Sheet1"). Does the Rothschild family own most central banks? Has a movie ever referred to a later movie?

Reason: Peace keeping comment added Register To Reply 03-06-2014,09:10 AM #9 Leon V (AW) View Profile View Forum Posts Forum Contributor Join Date 06-22-2011 Location somerset MS-Off Ver Excel 2007 Posts This is the contents of my Personal.XLS file, ThisWorkbook object: Code: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) MsgBox "Hello BeforeSave" End Sub (If I delete the "Private" keyword, Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Cellcontents = Sheets("Form").Range("H12").Value If Cellcontents = "" Then Cancel = True MsgBox "Company Name is empty . Excel Vba After Save I > > have > > > > two problems:- > > > > > > > > 1) My code causes excel to crash > > > > 2) The

The reason I have done this is so if the workbook is opened by a user with there excel set to disable macros they see the page that the before save Excel Vba Workbook Before Save Event But I will be using this on a shared .xlsm file and because not all users will know how to use I want to "automate" it in this way. What I need is to be able to stop people saving it using the Save or Save As icon's/file menu options. The reason Excel is crashing is > > > because you are not telling the BeforeSave event to stop Excel from > trying > > > to save the file by

During this upgrade there may be some intermittent down time preventing access to the forum or certain features. Excel Vba Beforesave Saveasui Result is that user has saved workbook in the required open workbook state then after saving is returned to worksheet they were on when they saved so they could if required Share Share this post on Digg Del.icio.us Technorati Twitter Microsoft MVP - Excel Reply With Quote Feb 2nd, 2010,06:26 AM #3 tabea New Member Join Date Feb 2010 Posts 4 Re: 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

Excel Vba Workbook Before Save Event

Thanks again for you help Regards Steve Register To Reply 03-06-2014,07:36 AM #4 Leon V (AW) View Profile View Forum Posts Forum Contributor Join Date 06-22-2011 Location somerset MS-Off Ver Excel Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.EnableEvents = False startOver: If saveMessage = vbYes Then If Worksheets("Sheet1").Range("$J$6").Value = "" Then noInitials Worksheets("Sheet1").Range("$J$6").Select Application.EnableEvents = True Exit Sub ' have tried Cancel = Excel Vba Run Macro On Save Return Value Nothing Example This example prompts the user for a yes or no response before saving the workbook. Private Sub Workbook_beforesave Regards Steve Register To Reply + Reply to Thread Page 1 of 2 1 2 Last Jump to page: « Previous Thread | Next Thread » Thread Information Users Browsing this

Please remember to mark threads Solved with Thread Tools link at top of page.Please use code tags when posting code: [code]Place your code here[/code]Please read Forum Rules Register To Reply 03-06-2014,09:18 http://tubemuse.com/excel-vba/excel-usedrange-not-working.html You are in an event handler, the BeforeSave event, in fact, and are trying to save the workbook. Any suggestions? If i leave it in, it works as required when i manually save, just not when I saving calling the ThisWorkBook.Save in a seperate module. Workbook_beforesave Saveasui

  • Your feedback about this content is important.Let us know what you think.
  • No message box popup.
  • 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?
  • by pressing F8, the macro will execute the code 1 line at a > time.
  • I > > have > > > > two problems:- > > > > > > > > 1) My code causes excel to crash > > > > 2) The
  • Below is what i have...
  • To start viewing messages, select the forum that you want to visit from the selection below.

Thanks Code: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If ThisWorkbook.ReadOnly = False Then GoTo Continue ReadOnly: MsgBox "The workbook is read only, changes cannot be saved", vbExclamation, "Attention" I have stepped through when using this ThisWorkbook.Save from another module & it fires the beforesave event which I see the code running with no errors and in exactly the same Second, and more importantly, you need to figure out why events are disabled. ;) –Rory Oct 10 '14 at 10:01 @Goosebumbs : actually the problem is: how can I have a peek at these guys What is it about the template that doesn't work for you? -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional

I have a BeforeSave macro that works ok when you save manually, however there are 2 other instances that do not work: 1) Using "ThisWorkbook.Save" in another macro does not save Workbook_beforesave Example Excel like most programs has ways of recognising infinite loops and getting out of them it is possible that it just can't recognise the loop with two books open rather than Unable to Save!", vbOKOnly, "Check Cells" Exit Sub End If End Sub The problem is that I cannot save the file with the blank form because the macro prevents me from

Sorry it >>> is >>> a bit difficult to explain, but if you try and create an .xlt file with >>> the >>> code you originally gave me you will see

All rights reserved. Books, Holy Macro! Using transistor as switch, why is load always on the collector Mimsy were the Borogoves - why is "mimsy" an adjective? Excel Vba Before Save Not Working hence, when the user says, "no, don't save", that's exactly what happens.

But this is a BEFORE SAVE event so all the code in that macro will run before excel saves the cancel = true doesn't stop the save there and then. See the image below. Thanks h x x p: // w w w*mrexcel*com/forum/excel-questions/692982-visual-basic-applications-activeworkbook-save-workbook_beforesave-problems. check my blog I > have > > > two problems:- > > > > > > 1) My code causes excel to crash > > > 2) The inputbox comes up twice for

open the vb editor. Occurs before the workbook is saved. The contents of my Personal.xls (ThisWorkbook) is now as follows: Code: Public WithEvents App As Application Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel as Boolean) MsgBox "Hello Is there a way to enable events autoatically ? –Michael Walz Oct 10 '14 at 10:08 Events can't be disabled by default - they have to be disabled in

Thanks Andi "Rob Bovey" wrote in message news:[email protected] > "Andibevan" wrote in message > news:[email protected] > > This does create a problem when trying to save it as a The only difference is range locations. Can anyone explain what I'm doing wrong? How to handle swear words in quote / transcription?

In Workbook Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim WS As Worksheet For Each WS In Worksheets WS.Unprotect Password:="******" If WS.FilterMode Then WS.ShowAllData WS.Protect Password:="******", _ AllowFormattingCells:=True, _ when a user clicks save: Excel "I would like to save", VBA "ok but first do this" (your Workbook_BeforeSave runs) Excel "now can I save?", VBA "cancel = true, so no" The saveMessage, DoNotSaveMessage, and saveCopy routines all work fine and if they have entered their initials the file saves a copy with a date stamp and the initials as part of display the macro int the vb window.

Get User Submitted Data from a Prompt in Excel using VBA Macros How to prompt a user for their input in Excel. Use Save As" End If Really appreciate some ideas on this. I get a message box with "Hello Auto_Open" message. It displays my username.

I'm trying to delve into Event driven macros. Any idea why all of a sudden the events would be disabled as I've never written any code using that functionality? Register Help Remember Me? Portal Forum FAQ Calendar Forum Actions Mark Forums Read Quick Links View Site Leaders Knowledgebase Articles Blogs Resources Consulting Services Training PayPal Donation Advanced Search Forum What were you trying to do before save? –Passerby Sep 11 '12 at 8:29 Before the save I just called upon the macro.

excel-vba share|improve this question asked Oct 10 '14 at 9:51 Michael Walz 12.7k62645 the code between option explicit and the Workbook_BeforeSave subroutine does not run because its not called. the macro will run to the dot and stop. It means that you can only save the document with a .xls extension which is a problem if you are trying to create an .xlt file? "Rob Bovey" wrote in Thanks in advance for your help.