LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Why does my code run but have no effect?

I need to force the user to enable macros.

I have a before save procedure in my workbook which hides all the sheets
except for one with a message telling the user to enable macros, then saves
before unhiding the sheets again.

When I click the save button, the procedure is triggered, and the workbook
is saved with sheets hidden, but if I call the procedure from the beforeclose
event procedure, and step through, all the code appears to run correctly, and
in the right order, but has no effect. ie the sheets are not hidden and the
workbook is not saved.







Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
Sheets("Macros Disabled").Visible = True
For Each ws In ThisWorkbook.Sheets
If ws.Name < "Macros Disabled" Then ws.Visible = False
Next

Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = True

For Each ws In ThisWorkbook.Sheets
ws.Visible = True
Next
Sheets("Macros Disabled").Visible = False
Sheets("Calendar").Visible = False

End Sub

 
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
Shadow Effect Gene L. New Users to Excel 4 December 1st 09 03:01 AM
the change does not take effect Frank Situmorang[_3_] Excel Worksheet Functions 1 August 4th 09 01:28 PM
Text Effect A.Mourice[_2_] Excel Discussion (Misc queries) 1 November 4th 08 02:09 PM
The Links Effect Shaka Excel Discussion (Misc queries) 0 July 20th 07 01:42 PM
Typewriter Effect Skydiver Excel Discussion (Misc queries) 5 June 5th 06 10:15 PM


All times are GMT +1. The time now is 09:06 AM.

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

About Us

"It's about Microsoft Excel"