Home > Excel Vba > Excel Beforesave Event Not Working

Excel Beforesave Event Not Working

Contents

hope this makes sense. After this code is run, the excel event asking if I would like to save changes pops up. How can I claim compensation? The purpose of my original post was to see if there is a way to achieve the above in the event a user happens to click on the system "Save" button check over here

I have set up code which allows me to be able to SaveAs in other locations while still keeping all sheets hidden upon saving. 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 I found very nice workaround in the net and I dare to quote it here: Private Sub Workbook_BeforeClose(Cancel As Boolean) ..... What is the most someone can lose the popular vote by but still win the electoral college?

Workbook_beforesave Not Working

I already tested it for your purposes and it works fine. It has if statements to handle the situation of whether or not it is a saveAs and whether or not it is a save w/closing or w/o closing the file. It won't select cells or unprotect the worksheet or activate different sheets. If you close the Workbook using the top right X this will trigger the Workbook_BeforeClose the document is expected to be closed in that event.

  1. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim tempName As String Dim newName As String Application.EnableEvents = False Application.DisplayAlerts = False tempName = Me.Name With Me.Sheets("Sheet1") ' Change to
  2. The time now is 08:42 AM.
  3. How to prove that authentication system works, and that the customer is using the wrong password?
  4. One would think the BeforeSave event handler is an ideal place toplace suchmake-visible-make-invisible logic, but alas...
  5. I > have > > > two problems:- > > > > > > 1) My code causes excel to crash > > > 2) The inputbox comes up twice for
  6. Float matrix left among other matrices Blueprint a sestina more hot questions question feed lang-vb about us tour help blog chat data legal privacy policy work here advertising info mobile contact
  7. The solution I found was to add code to ThisWorkbook module like the following: Code: Private Sub Workbook_Open() ' Remove Design mode buttons (design mode disables macros): Application.CommandBars("Visual Basic").Controls("Design Mode").Enabled =
  8. Share Share this post on Digg Del.icio.us 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
  9. End Sub I only encouter this problem when a SaveAs code is combined with BeforeSave code.

Else ''' Save as xlt here. Id apreciate some help in this matter, and i hope i made my self clear. Home Help Needed With A Beforesave/beforeclose Events: Similar Topics | Similar Excel Tutorials | Helpful Excel Macros Help Needed With A Beforesave/beforeclose Events: - Excel View Answers I'm probably going to Workbook_beforesave Example If I just close the floating toolbar, then the "Exit Design Mode" toolbar is no longer available from that point forward.

Code ladder, Cops Why is looping over find's output bad practice? Excel Vba Run Macro On Save Use Save As" End If Really appreciate some ideas on this. Background: 1) I have some code in the BeforeSave Event in the ThisWorkbook object where approximately half way through the event I force the model to save by using the line The end of the > event procedure should look like this: > > ErrorExit: > ''' This makes sure events get turned back on again no matter what. > Application.EnableEvents =

Thks for help. Excel Vba Beforesave If WorksheetFunction.CountA(Worksheets("Sheet1").Range("D5,D7,D9,D11,D13, D15")) < 6 Then MsgBox "Workbook will not be saved unless" & vbCrLf & _ "All required fields have been filled in!" Cancel = True End If End Sub 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 / Arts Culture / Recreation I like to call my class ImAGoodListener.

Excel Vba Run Macro On Save

If one steps through the code, it passes through the code like it worked correctly, but if you go look at the sheet, it is not protected/unprotected (whichever one is trying At least that makes some sence to me. Workbook_beforesave Not Working Hot Network Questions Changing 'theorem' to 'Theorem' while using \cleveref{} What is the most someone can lose the popular vote by but still win the electoral college? Workbook_beforesave Saveasui 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.

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 check my blog ActiveSheet.Protect has no effect in the BeforeSave code if this code is called by the SaveAs code)? You really should incorporate some sort of error trapping or other code to accommodate for that issue. Here is the FAQ for this forum. + Reply to Thread Results 1 to 15 of 15 BeforeSave Problem Thread Tools Show Printable Version Subscribe to this Thread… Mark this thread Private Sub Workbook_beforesave

You can save the workbook as a template by changing your SaveAs line to the following: ActiveWorkbook.SaveAs _ Filename:=FilePath & varInput & ".xlt", _ FileFormat:=xlTemplate -- Rob Bovey, Excel MVP Application 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 The only solution I can see is to then rename the file to the template.. "Andibevan" wrote in message news:%[email protected] > Thanks Rob - thanks for explaining it as well this content My boss asks me to stop writing small functions and do everything in the same loop Does the Rothschild family own most central banks?

Are you sure you have macros enabled? Excel Vba Run Macro Before Save Can anyone confirm that this is the "proper" programming practice to avoid the dreaded repeating Save prompt? Ask Your Own Question Disable Design Mode Problem - Excel Excel Forum Hi All - I've got a project I'm working where I'm trying to disable the user from turning on

Did I cheat?

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 See ASP.NET Ajax CDN Terms of Use – http://www.asp.net/ajaxlibrary/CDN.ashx. ]]> Please enable cookies. This parts works fine! Excel Vba On Save Event The workbook cannot be saved until there is data in each of the following cells: D5, D7, D9, D11, D13, and D15.

There are 4 ... this is a good de-bug tool. Peter, did I get that right? http://tubemuse.com/excel-vba/excel-vba-double-click-event-not-working.html Thank you! –Davuz Mar 7 '12 at 14:25 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted This kind of functionality requires...

The reason Excel is crashing is > because you are not telling the BeforeSave event to stop Excel from trying > to save the file by setting the Cancel argument to The only difference is that the word "Save" in the second code is capitalized but that is only because I have a code running that has everything in proper case. Here is the complete code I'm currently using: Code: Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.DisplayAlerts = False Sheets("Warning").Visible = True Sheets("PrimeCo Home").Visible = xlVeryHidden Sheets("Mel").Visible = False Sheets("Syd").Visible = False End I just created a template with the BeforeSave event procedure in it and it seems to work fine here.

Every time it imports data, I get the following message box appearing: "This operation will cause some merged cells to unmerge. This works great, except when they close the workbook and save the file because if it fails, then the workbook still closes. Thanks! A typical scenario is where the programmer wants towarn a user when arequired Addin is not loaded, that is, the Addin isrequired to workon aspecialized type ofWorkbook.A big warning text box

I am also using the same thing as an workbook before close event but when i exit using button it also displays the befoeclose event message see the code below Code: If so then you need to set up some application-level events. I have a BeforeSave event, that asks the user if they wish to save and continue, to save and exit, or to cancel. The sheet is not protected, and if you try to unprotect a protected worksheet, that does not work either.

Thanks in Advance![/list] Free Excel Help Forum - Ask any question about Excel and have it answered in no time. then click the start macro icon. Sub Problem() ActiveWorkbook.SaveAs FileName:="C:\WINNT\Profiles\ncc\Desktop\Help.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub Now that works fine and dandy, UNLESS you have BeforeSave code in the workbook such as this: Private I forgot about the "SaveAsUI As Boolean" which gives us useful info, namely is the Save (or SaveAs) instigated by the user via the UI or due to some code, such

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 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 Private Sub Workbook_BeforeClose(Cancel As Boolean) StartQuestion: Cancel = True 'Evaluate if workbook is saved and emulate default propmts With ThisWorkbook Select Case MsgBox("Do you want to save the changes you made