nerd humor
Apr. 7th, 2004 05:04 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
i was searching the net to find the "before save" event in vba and i came across this great exchange on the usenet. (edited to protect the innocent, and to make it less geeky.)
from humble nerd:
I no the subject sounds strange. Here's what I want to do:
Disable the "save" and the "save as" functions
Any ideas...?
--------------------------------
from codegod:
Utilise the BEFORE_SAVE event
Simply enter
CODE
If Range("X")="" or range("Y") = "" or range("Z") = "" then cancel = true
where X,Y and Z are your range references
Rgds, codegod
--------------------------------
from: humblenerd
I tried this:
Cancel = True
And nothing.
I also tried creating:
Public Sub
Cancel = True
End Sub
And called this from the worksheet but nothing.
Basically I need to disable the save and save as features unless certain cells are completed.
--------------------------------
from: codegod
As I stated in the 1st line of my response
Quote:
Utilise the BEFORE_SAVE event
This needs to go in the WORKBOOK module
Double click on the Thisworkbook in the projects window in VBE
Choose "Workbook" from left side dropdown
Choose "Before Save" from the right side dropdown
Put the code in there
Rgds, codegod
-----------------
from: humblenerd
Think I might have painted myself into a corner here.
I've got that script working a treat - just one snag.
I can't save it.
from humble nerd:
I no the subject sounds strange. Here's what I want to do:
Disable the "save" and the "save as" functions
Any ideas...?
--------------------------------
from codegod:
Utilise the BEFORE_SAVE event
Simply enter
CODE
If Range("X")="" or range("Y") = "" or range("Z") = "" then cancel = true
where X,Y and Z are your range references
Rgds, codegod
--------------------------------
from: humblenerd
I tried this:
Cancel = True
And nothing.
I also tried creating:
Public Sub
Cancel = True
End Sub
And called this from the worksheet but nothing.
Basically I need to disable the save and save as features unless certain cells are completed.
--------------------------------
from: codegod
As I stated in the 1st line of my response
Quote:
Utilise the BEFORE_SAVE event
This needs to go in the WORKBOOK module
Double click on the Thisworkbook in the projects window in VBE
Choose "Workbook" from left side dropdown
Choose "Before Save" from the right side dropdown
Put the code in there
Rgds, codegod
-----------------
from: humblenerd
Think I might have painted myself into a corner here.
I've got that script working a treat - just one snag.
I can't save it.