Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default after save event/procedure

What do mean by "I'm trying to write something that will save the workbook
in its initial state." What is the initial state? Otto
"kev_06" wrote in
message ...

Since most of the people that view this workbook may not enable their
macros at start, the workbook doesn't do anything. I've added a sheet,
Sheet 1, that explains this and tells them to enable macros. I want
this sheet to be the first one displayed whenever the workbook is open.
This is fine when macros are enabled, but it isn't when they are
disabled. So, I'm trying to write something that will save the workbook
in its initial state and then return to the sheet after the save has
been completed.

The code:

Public strname As String

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
strname = ThisWorkbook.ActiveSheet.Name

Cancel = True
Application.EnableEvents = False

Sheet4.Visible = xlSheetHidden
Sheet1.Visible = xlSheetVisible

Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
wks.Protect
wks.EnableSelection = xlNoSelection
Next wks

ThisWorkbook.Save
ThisWorkbook.Saved = True
Application.EnableEvents = True

Sheet1.Select
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)

If strname = "" Then
Exit Sub
ElseIf Worksheets(strname).Name = "Sheet1" Then
Exit Sub
Else
Worksheets(strname).Select
strname = ""
End If
End Sub


--
kev_06
------------------------------------------------------------------------
kev_06's Profile:
http://www.excelforum.com/member.php...o&userid=35046
View this thread: http://www.excelforum.com/showthread...hreadid=550078



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
workbook_Open event Procedure peerless Excel Discussion (Misc queries) 0 May 22nd 06 10:16 PM
Event Procedure not working AD108 Excel Programming 4 April 13th 06 08:06 PM
Event Procedure Paul Johnson[_2_] Excel Programming 1 February 2nd 05 01:29 PM
Event Procedure again Paul Johnson[_2_] Excel Programming 1 February 2nd 05 01:28 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"