|
-
Mar 6th, 2006, 08:02 AM
#1
Thread Starter
Lively Member
-
Mar 6th, 2006, 11:46 AM
#2
Re: save on Sheet Close
what code you want to write? what is your need?
Please explain little more. so that we can understand better to help you.
-
Mar 6th, 2006, 11:35 PM
#3
Thread Starter
Lively Member
Re: save on Sheet Close
i want to save the cells value to the database and sheet On YES click
-
Mar 7th, 2006, 12:07 AM
#4
Fanatic Member
Re: save on Sheet Close
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
-
Mar 7th, 2006, 03:45 AM
#5
Thread Starter
Lively Member
Re: save on Sheet Close
sorry i am not looking for it
i want the code on ,when MS-Excel give the Message on sheet/book close ,on YES
-
Mar 7th, 2006, 05:40 AM
#6
Re: save on Sheet Close
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.
-
Mar 7th, 2006, 05:44 AM
#7
Re: save on Sheet Close
Works too but VBAHacks code is making sure its not "Save As" as to retain the original workbook name.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 7th, 2006, 09:25 AM
#8
Thread Starter
Lively Member
Re: save on Sheet Close
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'
-
Mar 7th, 2006, 09:54 AM
#9
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 7th, 2006, 11:24 AM
#10
Re: save on Sheet Close
 Originally Posted by pandey_om
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'
We are not sure what you are looking for?
Do you want to click "Yes" buton?
or
Do you want to save some values to database if the user clicks the "Yes" button?
-
Mar 8th, 2006, 12:26 AM
#11
Thread Starter
Lively Member
Re: save on Sheet Close
i want to save some values to database if the user clicks the "Yes" button?
-
Mar 8th, 2006, 01:46 AM
#12
Thread Starter
Lively Member
Re: save on Sheet Close
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
-
Mar 8th, 2006, 02:50 AM
#13
Re: save on Sheet Close
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 8th, 2006, 03:47 AM
#14
Thread Starter
Lively Member
Re: save on Sheet Close
i think it will work for me
thankx u
-
Mar 8th, 2006, 07:39 AM
#15
Thread Starter
Lively Member
Re: save on Sheet Close
on clicking "YES"
1) Data are saved to database(Working Fine)
But 2) worksheet not close and MS-Excel Msg remainnig
-
Mar 8th, 2006, 07:45 AM
#16
Thread Starter
Lively Member
Re: save on Sheet Close
3) worksheet not saved
its working fine for Excel closed but not for sheet closed
-
Mar 8th, 2006, 11:33 AM
#17
Re: save on Sheet Close
How could Excel close but not a sheet?
Take the "Cancel = True" out.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 9th, 2006, 12:33 AM
#18
Thread Starter
Lively Member
Re: save on Sheet Close
thanks for your support
all working fine but one problem is that when i click YES ,in database records saved two times.
-
Mar 9th, 2006, 12:53 AM
#19
Thread Starter
Lively Member
Re: save on Sheet Close
i think problem is due to ME.Save or any
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|