Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Save VBA without saving the workbook?

I have some vba code that requires 4 cells to be completed on BeforeSave.
The code works great, but I need to be able to save the code without having
to complete the 4 fields in the worksheet because I want users to open the
worksheet with the 4 cells empty. I originally created some WorksheetOpen
code that emptied the 4 fields. But, I need users to be able to complete all
4 fields and save and reopen again with the fields complete so that code
won't work. This is driving me nutty. Any suggestions? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Save VBA without saving the workbook?

Greetings Alex,

How about opening the Excel with Macros disabled and clearing out the cells?

Br, Mani

"Alex" wrote:

I have some vba code that requires 4 cells to be completed on BeforeSave.
The code works great, but I need to be able to save the code without having
to complete the 4 fields in the worksheet because I want users to open the
worksheet with the 4 cells empty. I originally created some WorksheetOpen
code that emptied the 4 fields. But, I need users to be able to complete all
4 fields and save and reopen again with the fields complete so that code
won't work. This is driving me nutty. Any suggestions? Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Save VBA without saving the workbook?

I originally did that, but then I realized that someone may want to save all
4 completed cells and then open the saved file at a later date. I wouldn't
want them to open the file and clear out the cells.

"Mr_Mani" wrote:

Greetings Alex,

How about opening the Excel with Macros disabled and clearing out the cells?

Br, Mani

"Alex" wrote:

I have some vba code that requires 4 cells to be completed on BeforeSave.
The code works great, but I need to be able to save the code without having
to complete the 4 fields in the worksheet because I want users to open the
worksheet with the 4 cells empty. I originally created some WorksheetOpen
code that emptied the 4 fields. But, I need users to be able to complete all
4 fields and save and reopen again with the fields complete so that code
won't work. This is driving me nutty. Any suggestions? Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Save VBA without saving the workbook?

disable events while you save the file.

in the immediate window in VBA type

Application.EnableEvents = False

save the file, then set events to True to turn them back on. I've got a
toggle button on my toolbar assigned to a macro to do this.

Sub ToggleEvents()
With Application
.EnableEvents = Not .EnableEvents
If .EnableEvents Then
.StatusBar = False
Else: .StatusBar = "Events Are Disabled"
End If
End With
End Sub



"Alex" wrote:

I originally did that, but then I realized that someone may want to save all
4 completed cells and then open the saved file at a later date. I wouldn't
want them to open the file and clear out the cells.

"Mr_Mani" wrote:

Greetings Alex,

How about opening the Excel with Macros disabled and clearing out the cells?

Br, Mani

"Alex" wrote:

I have some vba code that requires 4 cells to be completed on BeforeSave.
The code works great, but I need to be able to save the code without having
to complete the 4 fields in the worksheet because I want users to open the
worksheet with the 4 cells empty. I originally created some WorksheetOpen
code that emptied the 4 fields. But, I need users to be able to complete all
4 fields and save and reopen again with the fields complete so that code
won't work. This is driving me nutty. Any suggestions? Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Save VBA without saving the workbook?

You could put a key in to check first:

if worksheets("sheet99").range("a1").value = "Alex" then
'do nothing
else
'your code to verify the cells are non-empty
end if

or

if lcase(application.username) = "alex lastname" then

or you could cheat...

Hit alt-f11 to get to the VBE
hit ctrl-g to see the immediate window
type this and hit enter:

application.enableevents = false

Then back to excel and save the workbook the way you want. You've disabled
events, so _beforesave won't fire.

Toggle it back with:
application.enableevents = true



Alex wrote:

I originally did that, but then I realized that someone may want to save all
4 completed cells and then open the saved file at a later date. I wouldn't
want them to open the file and clear out the cells.

"Mr_Mani" wrote:

Greetings Alex,

How about opening the Excel with Macros disabled and clearing out the cells?

Br, Mani

"Alex" wrote:

I have some vba code that requires 4 cells to be completed on BeforeSave.
The code works great, but I need to be able to save the code without having
to complete the 4 fields in the worksheet because I want users to open the
worksheet with the 4 cells empty. I originally created some WorksheetOpen
code that emptied the 4 fields. But, I need users to be able to complete all
4 fields and save and reopen again with the fields complete so that code
won't work. This is driving me nutty. Any suggestions? Thanks.


--

Dave Peterson
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
close workbook without saving or promt to save ATVNSHANE Excel Discussion (Misc queries) 3 February 4th 10 03:57 PM
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Macro file save as, saving sheet not workbook annep[_10_] Excel Programming 15 January 21st 06 10:39 PM
Workbook.Save not saving the updates [email protected] Excel Programming 2 May 6th 05 04:41 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM


All times are GMT +1. The time now is 05:11 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"