View Single Post
  #20   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default CATCH-22 won't let me save the file - Dave Peterson

And google is nice, too!!

Jason, Frederick wrote:

Dave,
Your are a the MASTER! Thank you. I have been pulling my hair out for the last 6 hours because no one on here really either understood the initial question or just had no clue.
The bottom line was, the code needed to be saved and that could not be done because the code was running.
Thank you for providing the "immediate window" and "application.enableevents = false" command thus allowing me to save the file blank.
Jason

Dave Peterson wrote:

CATCH-22 won't let me save the file
26-Mar-08

Before you (as the developer, not the user) save the file, you can turn off
events.

Open the VBE
hit ctrl-g to see the immediate window
type this and hit enter:
application.enableevents = false

Then save your workbook--the _beforesave event won't fire.

Then back to the VBE and toggle the setting in the immediate window:
application.enableevents = true

====
You could also do other stuff, too. Maybe check the username?

if lcase(application.username) = lcase("Patrick Riley") then
'do nothing, let it save...
'or clear that cell!
me.sheets("Main").range("e59").value = ""
else
If IsEmpty(me.Sheets("Main").Range("E59").Value) Then
MsgBox "You must type in your name before " & _
"this file can be saved.", 16, "ERROR"
Cancel = True
End If
end if

Patrick Riley wrote:

--

Dave Peterson

EggHeadCafe - Software Developer Portal of Choice
ASP.NET Session State FAQs
http://www.eggheadcafe.com/tutorials...state-faq.aspx


--

Dave Peterson