Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA - BeforeSave - NEED HELP

I created a form (to be used like a template) in Excel
(saved as xls. not xlt.) In order to ensure that the form
is filled out in it's entirety, I wrote a code in VBA
(using BeforeSave) that will not allow the file to be
saved if certain cells are blank. Unfortunately though, I
am now unable to save my file for others to use...since
these cells are blank. They need to be blank when the
file is open, so that others can fill them in. Any
suggestions would be greatly appreciated. Please help.
Thank You.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default VBA - BeforeSave - NEED HELP

I use a toolbar button to turn events on and off. In the off position the
event is disabled and you can do what you want. The code also changes
the caption of the button to let me know where I stand. [watch word
wrap]

Private Sub EnableAllEvents()

Select Case Application.EnableEvents
Case False
Application.EnableEvents = True
Application.CommandBars("SB2").Controls(3).Caption = "Disable
Events"
Case True
Application.EnableEvents = False
Application.CommandBars("SB2").Controls(3).Caption = "Enable Events"
End Select
Application.ScreenUpdating = True
End Sub


--
sb
"HRobertson" wrote in message
...
I created a form (to be used like a template) in Excel
(saved as xls. not xlt.) In order to ensure that the form
is filled out in it's entirety, I wrote a code in VBA
(using BeforeSave) that will not allow the file to be
saved if certain cells are blank. Unfortunately though, I
am now unable to save my file for others to use...since
these cells are blank. They need to be blank when the
file is open, so that others can fill them in. Any
suggestions would be greatly appreciated. Please help.
Thank You.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default VBA - BeforeSave - NEED HELP

H,

Wrap your code in something like this:

If Application.UserName < "Bernie Deitrick" Then
MsgBox "I'm running the code"
'Code here
Else
MsgBox "I'm not running the code because you're the guy in
charge."
End If

Of course, change the "Bernie Deitrick" to whatever
Application.UserName returns for you.

HTH,
Bernie
MS Excel MVP

"HRobertson" wrote in message
...
I created a form (to be used like a template) in Excel
(saved as xls. not xlt.) In order to ensure that the form
is filled out in it's entirety, I wrote a code in VBA
(using BeforeSave) that will not allow the file to be
saved if certain cells are blank. Unfortunately though, I
am now unable to save my file for others to use...since
these cells are blank. They need to be blank when the
file is open, so that others can fill them in. Any
suggestions would be greatly appreciated. Please help.
Thank You.



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
Event (BeforeSave) - How to test VBA code? Dave P. can you hear me now? EagleOne Excel Discussion (Misc queries) 3 September 14th 06 07:46 PM
BeforeSave event Carl Bowman Excel Discussion (Misc queries) 4 February 6th 05 12:28 PM


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