Hi Experts, :wave:
On closing an excel sheet the excel provoid the mgs;
do u want to save the change in file.xls
YES NO CANCLE
i wana the write some code on YES click
PLZ HELP :thumb:
Printable View
Hi Experts, :wave:
On closing an excel sheet the excel provoid the mgs;
do u want to save the change in file.xls
YES NO CANCLE
i wana the write some code on YES click
PLZ HELP :thumb:
what code you want to write? what is your need?
Please explain little more. so that we can understand better to help you.
i want to save the cells value to the database and sheet On YES click
I believe what you are looking for is the BeforeSave workbook event. Place this on your workbook code sheet and modify the stuff in the middle:
VB Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim iReply As Integer If SaveAsUI = True Then iReply = MsgBox("Sorry, you are not allowed to save this Workbook as another name. " _ & "Do you wish to save this workbook.", vbQuestion + vbOKCancel) Cancel = (iReply = vbCancel) If Cancel = False Then Me.Save Cancel = True End If End Sub
sorry i am not looking for it
i want the code on ,when MS-Excel give the Message on sheet/book close ,on YES
I haven't tested, but I think the only code you need in the Sub from VBAhack's example is this:
..however, you will probably want to put it into the BeforeClose event instead of BeforeSave.VB Code:
Me.Save
Works too but VBAHacks code is making sure its not "Save As" as to retain the original workbook name.VB Code:
ThisWorkbook.Save
sorry i am not looking for it
i want the code on ,when MS-Excel give the Message box on sheet/book close
DO you want to save the changes made in .xls file
YES NO Cancle
i wana code on only cliking 'YES'
See post #4.
We are not sure what you are looking for?Quote:
Originally Posted by pandey_om
Do you want to click "Yes" buton?
or
Do you want to save some values to database if the user clicks the "Yes" button?
i want to save some values to database if the user clicks the "Yes" button?
the steps are
1)open work sheet
2)write data on sheet
3)on closing sheet
MS-Excel Messg "DO you want to save chang...."
YES , NO, Cancel
if i click YES the data must be save, not on click NO and Cancle
:)VB Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If Cancel = False And SaveAsUI = False Then Me.Save Cancel = True 'Add code to save data to database here: ' End If End Sub
i think it will work for me
thankx u
on clicking "YES"
1) Data are saved to database(Working Fine)
But 2) worksheet not close and MS-Excel Msg remainnig
3) worksheet not saved
its working fine for Excel closed but not for sheet closed
How could Excel close but not a sheet?
Take the "Cancel = True" out.
thanks for your support
all working fine but one problem is that when i click YES ,in database records saved two times.
i think problem is due to ME.Save or any