Prevent Close Code Until Message Confirmed
Apr 23, 2008
I have a spreadsheet with a number of fields on it which must be filled in before the file can be saved, and if the user attempts to close the spreadsheet without filling in the required fields, I want a message box to appear asking for confirmation that the user wishes to quit, if yes, the sheet exits, if no, the sheet remains open
View 2 Replies
ADVERTISEMENT
Apr 1, 2014
At the time of opening the file some macros are running automatically in my file as per my requirement. If auto filter is on then it disturbs my program. Sometimes I forget to remove auto filter before closing the file and it cause a problem in my file after opening it again.
Requirement is: Is there any code to prevent the file closing if the auto filter is on and give me a warning message 'Please remove auto filter first'.
View 2 Replies
View Related
Jun 29, 2007
I have an accounting spreadsheet that is used by 25-30 people. This spreadsheet has a button the user can use to save this spreadsheet allowing the spreadsheet to save itself to a specific folder path base on the dates entered in the spreadsheet.
I have begun tracking certain items in the accounting spreadsheet and have added a section to the save macro that gathers data from the accounting spreadsheet and saves the data to a ‘Spreadsheet Stats’ spreadsheet. Since it was possible that more than one person might try saving the spreadsheet at the same time and try to open the ‘Spreadsheet Stats’ spreadsheet at the same time, I placed a loop in the macro that determines if the 'logging data' spreadsheet when opened is marked as "read-only". If the ‘Spreadsheet Stats’ spreadsheet is opened as "read-only", the macro closes the ‘Spreadsheet Stats’ spreadsheet then reopens the ‘Spreadsheet Stats’ spreadsheet again and again until opened without the "read-only" status. Code seen below.
Do Until Now() = start_time + 0.002082 Or Now() > start_time + 0.002082
Workbooks.Open Filename:= _
"G:EDCUSTSERV1_ACCTGIPL SpreadsheetsBilling SpreadsheetsData DropSpreadsheet Stats.xls"
Set WB = ActiveWorkbook
If WB.ReadOnly = False Then
Exit Do
End If
WB.Close
Loop
The macro works great, however, should a user try to save the spreadsheet and the loop happens to open and reopen the spreadsheet until the "read-only" status is gone, when the macro completes, a window pops up and alerts the user that the ‘Spreadsheet Stats’ spreadsheet is now available for editing.
My question: Is there any way to prevent that pop up window? I don’t want the user to think they need to edit the ‘Spreadsheet Stats’. Remember that the macro has completed when the popup window shows up, so Application.display alerts set to false
View 2 Replies
View Related
Feb 8, 2007
I've developed a little software using Excel Macros & VB. To prevent people from accesing the code I protected the code blocking it from visualization. It seems not enough as an acquaintance of a friend cracked it in 25 minutes. Or so he says. So I'd like to know if there is a better way to protect the font code.
View 8 Replies
View Related
May 11, 2009
is it possible to have a messagebox activate when closing a workbook.
View 9 Replies
View Related
Oct 17, 2006
I have an extensive application which I wrote using Excel 2002 (XP - Version 10). However it will likely be used on anything ranging from 2003 - 1997. When I tested it using Excel 97 it gave me the traditional [annoying] message asking if I was sure I wanted to save it under an earlier version than which it was created.
I want to get rid of this message (a lot of my users aren't the most computer literate and the more annoying messages I can avoid the better!)
I tried using:
Application.DisplayAlerts = False
but it doesn't affect this particular message. I need to know how to keep this message from popping up. Please Help.
Under 97 (NOT on my 2002) it also gives a "Do you want to save the changes" message upon closing even though the "DisplayAlerts" is set to false. I'm not sure why this is still coming up.
View 9 Replies
View Related
Sep 12, 2007
When I open an excel file it asks if Id like to update the links to other data sources. I would like to say no everytime, does anyone know the VB to avoid the popup?
View 4 Replies
View Related
Oct 17, 2007
When processing workbooks via VBA, on closing the workbook I sometimes get a request to respond to whether I want to save the clipboard. In the same way that there is the option to open a workbook without refreshing links: workbooks.open updatelinks:=False
I assume there is something on the order of: workbook.close DontSaveClipboard:=True
Question #1 is: What is the parameter syntax for saving or not saving the clipboard?
Question #2 is: Where would I go to look up these parameter settings instead of having to come back to the group every time I find the next one I need?
View 3 Replies
View Related
Dec 13, 2007
Application starts with a button on an otherwise empty spreadsheet. Then opens a user form. After I close using a button on the form. My close routine closes the worksheets and workbooks. I then quit the application and I get a message asking if I want save the original spreadsheet.
View 6 Replies
View Related
Sep 7, 2007
I am running Excel 97 on one PC and 2003 on another, both need access to a workbook and both need to amend that workbook.
In my Macros I have a line in the Workbook to save etc
Workbooks("WB Name").Close SaveChanges:=True
When I run the macro on the 97 PC I get a message stating that the "file was created with a newer version of Excel Continue with save Y/N"
I have tried
Application.DisplayAlerts = False
Workbooks("WB Name").Close SaveChanges:=True
Application.DisplayAlerts = True
but the file does not save.
View 4 Replies
View Related
Apr 22, 2009
As an example, I have this code to open a message box saying "Hello" when Excel opens.
View 4 Replies
View Related
Jul 28, 2007
I am trying to write VB code that upon opening an excel spreadsheet a message box appears that the user must read, than select yes or no. If select yes than the file will open, if no the file closes or does not open. Here is what i have tried - it doesn't work.
Sub Auto_Open()
YesNo = ("Are you sure you want to open?",vbYesNo + vbExclamation,"Will")
If_vbYes Exit_Sub
If_vbNo_Close
End Sub
View 9 Replies
View Related
Sep 11, 2013
What is this error message that is popping up when I try to insert a blank row of cells?
"To prevent possible loss of data, Excel cannot shift nonblank cells off of the worksheet. Select another location in which to insert new cells, or delete data from the end of your worksheet.
If you do not have data in cells that can be shifted off the worksheet, you can reset which cells Excel considers nonblank. To do this, press CTRL + End to locate the last nonblank cell on the worksheet. Delete this cell and all cells between it and the last row and column of your data then save."
This excel document we have has LARGE amounts of data
View 3 Replies
View Related
May 12, 2013
VB:
Sub exitbox()
MsgBox "This will close in 20 seconds"
If Application.Wait(Now + TimeValue("00:00:20")) Then [code]...
I am trying to close this msgbox 20 seconds from now, but I cannot get it working.
View 2 Replies
View Related
Oct 13, 2008
how do i go about setting a message box to pop up every 10 mins or so prompting the user to close the workbook.? i want it to be as irritating as possible! iv'e had a look at ontime but cant get my brain into gear!also don't some of these timers fire even if workbook closed?
View 4 Replies
View Related
Apr 4, 2007
Is there a macro to close this msg box:
"There is a large amount of information on the Clipboard. Do you want to ...."
I wish for the default to be no which I believe will be FALSE. But I do not know the command
View 4 Replies
View Related
May 16, 2014
Is there a code that can be input to prevent a document from being printed?
View 8 Replies
View Related
Jul 11, 2009
I know this is the code to close a workbook
View 5 Replies
View Related
Mar 30, 2007
I can save and create pdf, I just need help deleting the .xls file.
Her is code I have:
ActiveWorkbook.Save
Path = "C:Emailed Proposals"
On Error Resume Next
ActiveWorkbook.SaveAs Filename:= _
Path & Range("C6").Value & Range("O3").Value & ".xls"
On Error GoTo 0
Application.ActivePrinter = "PrimoPDF on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PrimoPDF on Ne00:", Collate:=True
Application.ActivePrinter = "EPSON Stylus C86 Series on Ne02:"
I need to keep the newly created .pdf and delete the created/saved .xls file, I just can't ssem to figure out what I need to write in code.
View 9 Replies
View Related
Sep 29, 2008
I have a template where users provide input in specified fields. Upon completion, pressing a macro button emails the file to administrator.
find out a code that once email is sent, perform following actions simultaneously;
Pop up message to appear as “Message Sent – Do you want to process another request?
If reply is Yes, the sheet is refreshed
If reply is No, File is closed without Saving
View 9 Replies
View Related
Jan 29, 2007
The code below works perfectly when run from a macro button on a worksheet or when initiated using the VBA run option in the VBA editor but it does not run when run from a command button on a userform. The code is
Sub closer()
Dim bCancel As Boolean
Do Until bCancel = True
bCancel = Application.Dialogs(xlDialogSaveAs).Show
If bCancel = False Then MsgBox "Sorry, cannot Cancel", vbCritical
Loop
ActiveWorkbook.Close SaveChanges:=False
End Sub
When I run the code from a command button on my userform the error message I get is: 'Run-Time error 1004 Document not saved' and the line of code that it continually gets stuck on is: bCancel = Application.Dialogs(xlDialogSaveAs).Show
View 2 Replies
View Related
Feb 9, 2009
Is there a way to prevent access to the code of a macro? I am interested in sending out some macro's, but would prefer that the user only be able to run them, and not be able to access the code via the edit button. Curiously, there have been occasion's where I wanted to edit my own work, but the edit button did not function, so I had to exit and start over to proceed. From this I'm guessing there must be a way.
View 2 Replies
View Related
Dec 1, 2011
I have a workbook that contains macros. When the workbook is protected, the macro returns an error so I have unprotected the workbook but, if someone protects the workbook and saves it, it returns an error when closing and even if they choose cancel, it still screws up the macro and prevents it from working upon reopen.
Is there a way to prevent someone from protecting the workbook in vb code?
View 7 Replies
View Related
Aug 15, 2012
Some code that would prevent my user form (calendar) from popping up when the worksheet is protected?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$G$8" Or Target.Address = "$G$14" Or Target.Address = "$G$17" Then
CalendarFrm.Show
End If
If Target.NumberFormat = "m/d/yy;@" Then
[Code] ........
View 7 Replies
View Related
Oct 19, 2007
I know how to enable/disable events using VBA code, however is there an option within excel to turn it on/off? My problem is this...
At the beginning of my code I disable events and at the end I enable it again (I need to do this to avoid being caught in a loop). However something is going wrong somewhere in my code and the code stops halfway through. I'm trying to test sections of the code, but I often inadvertently stop the code without enabling the events again. Therefore I can't get my VBA to execute again unless I close excel down and restart. This is a pain as I have to find my place in the code again!
View 5 Replies
View Related
Aug 15, 2008
This formula must be confirmed with CTRL+SHIFT+ENTER not just ENTER. You will see { } brackets appear.
View 3 Replies
View Related
Nov 2, 2007
I have a piece code that allows the user to pick a file from a folder on my C:. It then copies a range of data into the original workbook that the macro was run. I would like to close the other file down automatically which shouldn't be that hard but I can't work out how to do it.
View 9 Replies
View Related
Jun 26, 2009
I have a macro that runs and I want it to close excel when it is done. The best I can do is to get it to close the worksheet and workbook.
What is the code to make excel completely close?
View 9 Replies
View Related
Sep 7, 2009
I tried to use Workbooks("Inactivebookname.xlsm").Close False
and many variations thereof, but I simply cannot close this workbook when currently another workbook is active.
I have no problem in closing an active workbook with
ActiveWorkbook.Close
View 9 Replies
View Related
Dec 29, 2006
I am trying to inch my way forward to writing a macro that will read in an external CSV file into a sheet (my next task will be to spread the date between multiple sheets based on regions). My first attempt at code is the following
Sub read_csv()
Dim strLine As String
Dim i As Integer
Dim filename As String
Dim ans As String
filename = "C:Documents and SettingsMichaelMina dokumentMina datakällorD123905.csv"
Open filename For Input As #1
i = 1
While Not EOF(1) And i < 10
Line Input #1, sLine
ans = MsgBox(sLine, vbOK, "hello there")
i = i + 1
Wend
' Close filename
End Sub
A couple of problems arise. When I debug the code, if I remove the comment on the close filename, the debugger complains with error 13 (incompatible types). If I comment the line and try and run the code twice in a row, I get a complaint about error 55 - file already open. I'm guessing that the close filename is the correct syntax - if it isn't, what should it be??
View 5 Replies
View Related