View Full Version : save and close an excel sheet when I press the Windows + L buttons
pieiro
05-09-2016, 07:09 PM
Good afternoon,
I want to save and close an excel sheet when I press the Windows + L buttons
The sheet can not be shared and so it has to be closed by the last user in order to be updated by other users, it turns out that if a user forgets to close, all the work of other users of the sheet is compromised, it can not access the same.
Thank you in advance for your time.
Regards
Windows Key+L is to log off Windows.
When you log off from Windows, Excel is closed. If it is not saved, the User is prompted to save.
Please explain the situation you are having.
See Also: http://www.vbaexpress.com/kb/getarticle.php?kb_id=515
Paul_Hossler
05-10-2016, 07:14 AM
Windows Key+L is to log off Windows.
Splitting a hair here, but Win+L is to lock your PC or switch accounts, not quite the same as logging off
pieiro
05-10-2016, 08:14 AM
Windows Key+L is not to log off Windows is to looking off the pc.
Us old XP'ers ain't got no "Lock Computer." We only log off.
In any case, the Windows Key turns control over to the Start Menu API. Any running Applications are out of the picture at that point.
See if any of these help:
http://www.howtogeek.com/howto/windows-vista/disableenable-lock-workstation-functionality-windows-l/
https://www.tekrevue.com/tip/windows-8-start-menu-toolbar/
http://www.computerworld.com/article/2494657/microsoft-windows/10-windows-8-tips-tricks-and-hacks.html
http://www.bleepingcomputer.com/tutorials/remove-lock-option-from-user-menu-in-windows-8/
http://www.itworld.com/article/2988645/windows/best-free-app-for-hacking-windows-10s-start-menu-and-giving-one-to-windows-8.html
Aussiebear
05-10-2016, 11:28 PM
Us old XP'ers ain't got no "Lock Computer." We only log off.
How about you upgrade young fella before you "log off" this tiny world we live on?
crossposted
http://www.excelguru.ca/forums/showthread.php?6031-save-and-close-an-excel-sheet-when-I-press-the-Windows-L-buttons
I am thinking about it, Ted. If only so I can keep posting here.
Zavra says, "Hey." She came to visit me last month.:mbounce2: :love :grouphug:
pieiro
05-12-2016, 05:20 AM
let me ask you something, it is possible to save and close an Excel sheet by pressing two keys?
for example by pressing b + g
Record a Macro. The Wizard will have a space to select Hotkeys. It doesn't matter what you Record, (just select a cell and type something.)
Edit that Macro by replace any code in it with
Me.Save
Me.Close
You might want to save and close the book at other times and Events. You can Use a "Universal" Save and Close Sub and call it from that Macro.
Macro Code
Sub MacroName
'Some Macro comments
SaveAndClose
End Sub
Put the following in the same Code Module that the Macro gets saved in
Public Sub SaveAndClose()
Me.Save
Me.Close
End Sub
Public Sub CloseOnTime()
Static CloseTime As Date
'Cancel the previous close on time
If Not CloseTime = 0 Then _
Application.OnTime CloseTime, SaveAndClose, , False
CloseTime = DateAdd("s", 300, Now) 'The Workbook will close in 300 seconds
Application.OnTime CloseTime, SaveAndClose, , True
End Sub
Put the following Subs in the ThisWorkbook Module
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Save
End Sub
Private Sub Workbook_Open()
CloseOnTime
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
CloseOnTime
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
CloseOnTime
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
CloseOnTime
End Sub
Aussiebear
05-12-2016, 09:24 PM
Pieiro, if you feel the need to crosspost this thread, at least have the courage to indicate this to those members who are trying to assist.
pieiro
05-13-2016, 04:46 AM
Good afternoon,
I am very inexperienced in these things and do not know how to do what you ask me, can you tell me exactly what to do step by step so I can do what you ask?
Maybe with an example I can understand what to do.
Thank you
What is multiposting? (http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_new_faq_item3) Multiposting is the act of posting a single question to different forums around the same time.
We discourage multiposting because it is like calling five cab companies and going with the one that comes first -- it shows disrespect for the volunteers that monitor this forum because they will unknowingly be helping someone who may have already received help elsewhere. Their time is no less important than that of the person asking the question.
Many of the volunteers here visit multiple forums and can easily spot duplicate posts. Some of them may even reply to your posts with a link to your post on another forum. Don't be the person that gets caught.
If you must post your question on a different forum, include a link to the question you have already posted on the previous forum(s). That way, those helping you can decide for themselves if you are already receiving the help you need somewhere else.
If you are still confused, read A message to forum cross posters (http://www.excelguru.ca/node/7).
pieiro
05-13-2016, 05:26 AM
Actually I put the initial issue in other forums, but I am just follow this, since I have not had any contact from the other forums.
You can be sure that as soon as I have a solution to this question whether this or any other forum (unlikely since I have no answers) will be informed and the post will be closed as resolved.
pieiro
05-13-2016, 05:28 AM
Record a Macro. The Wizard will have a space to select Hotkeys. It doesn't matter what you Record, (just select a cell and type something.)
Edit that Macro by replace any code in it withMe.Save
Me.Close
Formatting tags added by mark007
You might want to save and close the book at other times and Events. You can Use a "Universal" Save and Close Sub and call it from that Macro.
Macro Code Sub MacroName
'Some Macro comments
SaveAndClose
End Sub
Formatting tags added by mark007
Put the following in the same Code Module that the Macro gets saved in
Public Sub SaveAndClose()
Me.Save
Me.Close
End Sub
Public Sub CloseOnTime()
Static CloseTime As Date
'Cancel the previous close on time
If Not CloseTime = 0 Then _
Application.OnTime CloseTime, SaveAndClose, , False
CloseTime = DateAdd("s", 300, Now)'The Workbook will close in 300 seconds
Application.OnTime CloseTime, SaveAndClose, , True
End Sub
Put the following Subs in the ThisWorkbook Module
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Save
End Sub
Private Sub Workbook_Open()
CloseOnTime
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
CloseOnTime
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
CloseOnTime
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
CloseOnTime
End Sub
I am very inexperienced in these things and do not know how to do what you ask me, can you tell me exactly what to do step by step so I can do what you ask?
Maybe with an example I can understand what to do.
Thank you
that is very basic VBA. Perhaps you should hire someone to work more closely with you.
pieiro
05-13-2016, 06:36 AM
all I have to do is copy and paste this code in VBA excel sheet in developer mode ????
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.