![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Posts: 206
|
The only way I have found is for the user (after the save) to do something to start the code. I would like to have it start automatically after the save. Is there a way to do this?
**EDIT- Maybe this will help. This is what I have: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Application.ScreenUpdating = False ActiveWorkbook.Unprotect Password:="mypassword" Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets If ws.CodeName = "Sheet24" Then ws.Visible = xlSheetVisible Else ws.Visible = xlSheetVeryHidden End If Next ws ActiveWorkbook.Protect Password:="mypassword" Application.ScreenUpdating = True End Sub The idea is to force users to enable macros or all they get is Sheet24. Sheet24 says "Macros must be enabled." I want to unhide the sheets immediately after the save. For now I double click Sheet24 to unhide the sheets. _________________ Win 98SE - Office 2K [ This Message was edited by: dsnbld on 2002-05-26 15:03 ] |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
I don't have a great answer for this but since you've been waiting awhile I thought I would give you what I've got.
One way of a person saves a file is by using the Shortcut key sequence Ctrl+s. You can capture this key stroke sequence and redirect it to your own "FileSaveProc". This way you could have the file save occur and what ever else you wanted. Just run this code on opening the workbook and the Ctrl+s would be re-directed to your own save procedure. Code:
Sub CaptureSaveKey()
' Capture Shortcut keys for saving
' and redirect to user defined save function
Application.OnKey "^s", "FileSaveProc"
End Sub
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 206
|
Thanks for your imput Nimrod.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|