LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Saving a very tricky code

Good suggestion.

I actually thought to myself, "great idea, I can use environ for quickly
switching between test and prod for my development".

After a 5 minute search, I can find no easy way to write out environment
variables (other than hitting the SetEnvironmentVariable API - and I'm
having trouble with that too!)

Have you got some code to share?


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bob Phillips" wrote in message
...
Another way is to use an environment variable rather than a file, and test
it with Environ.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Rob van Gelder" wrote in message
...
Two ways:

1.
Set a breakpoint at the End Sub then from the immediate window: Cancel =
False

2.
If you're doing this regularly, you may want an external flag.

For example
Instead of
Cancel = True
Try
If Dir("C:\DebugMode.txt") = "" Then Cancel = True

Then create DebugMode.txt whenever you plan to do some development.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Shilps" wrote in message
...
Hi,
I have a very tricky situation. I want to disble the save option of

the
workbook. So I wrote this code

Private Sub Workbook_BeforeClose(Cancel as Boolean)

Application.DisplayAlerts = False
ThisWorkbook.Saved = True
ThisWorkbook.Close
Application.DisplayAlerts = true

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel as Boolean)

Application.DisplayAlerts = False
Cancel = True
Application.DisplayAlerts = true

End Sub

Now the problem is the moment I write this code, it is activated

before
saving and this code is not saved at all. How do I save this code? My
objective is that the user should not be able to save any changes in the
workbook.
TIA
Shilps







 
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
Saving Vba Code Rick, United Kingdom Excel Discussion (Misc queries) 5 September 8th 05 08:51 PM
code lost after saving Glen[_3_] Excel Programming 2 October 29th 03 03:05 PM
Saving a Workbook without code KimberlyC Excel Programming 1 August 21st 03 07:07 PM
Code for saving as a .prn file Jim Rech Excel Programming 0 August 5th 03 01:38 PM
code for saving Pier Excel Programming 2 July 29th 03 12:25 PM


All times are GMT +1. The time now is 04:15 AM.

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"