MrExcel Publishing
Your One Stop for Excel Tips & Solutions

prevent people from use save as function in my workbook....please help me


Posted by Newby on March 31, 2000 3:46 AM

some1 have send this below code on this board..the problem
i've paste in it my workbook called "ACCOUNT"
but it dowsn't worked.any ideas why it doesn't work..
p/s : also 1 2 know what is UI stand in below code
thanks n regards


Private Sub workbook_beforesave(ByVal SaveAsUI As Boolean, cancel As Boolean)
MsgBox ("Sorry you cannot save this workbook using this method")
SaveAsUI = False
cancel = True
End Sub


Posted by Celia on March 31, 2000 4:32 AM

Private Sub workbook_beforesave(ByVal SaveAsUI As Boolean, cancel As Boolean) MsgBox ("Sorry you cannot save this workbook using this method") SaveAsUI = False cancel = True End Sub


You have to put the code into the Workbook module (not a normal module).
UI = User Input

Celia

Posted by Newby on March 31, 2000 4:39 AM

i stiil don't u/stand..where can i find it..could u help me more celia.thanks

Posted by Celia on March 31, 2000 4:55 AM

Re: i stiil don't u/stand..where can i find it..could u help me more celia.thanks

Open your workbook.
Open the VB editor by pressing ALT + F11.
Select View/Project Explorer.
You will see your workbook name in the Project list.
Under your workbook name you will see ThisWorkBook
Double click on ThisWorkBook.
The workbook code module will open.
Put the code in the module.

Celia


Posted by Newby on March 31, 2000 5:08 AM

thanks celia..will do it...n try it..thanks 4 the concerned..bye...


Posted by Paul on April 06, 2000 7:50 PM

Re: the save my work book will not save it.

I have put the code in the Workbook.

and It works great but, how do I save it in there as I must close the workbook. And it doesn't save the changes.

So the next time the template is opened. People can copy it again.

What am I not doing? Any ideas.

Posted by Ivan Moala on April 07, 2000 4:13 AM

Re: the save my work book will not save it.

and It works great but, how do I save it in there as I must close the workbook. And it doesn't save the changes. So the next time the template is opened. People can copy it again. What am I not doing? Any ideas.


If you are giving this workbook to other users
on there machines AND they don't have the same
Username as you then try this;

Private Sub workbook_beforesave(ByVal SaveAsUI As Boolean, cancel As Boolean)
if Application.Username <> "Your username goes here" then
MsgBox ("Sorry you cannot save this workbook using this method")
SaveAsUI = False
cancel = True
endif
End Sub

Ivan