Disallow "SAVE" only "SAVE AS" or prompt

G

Guest

Hello-

I have built a form using excel. I have protected all cells except user
inputs.

I'm wondering if there is a way to force the user to either exit without
saving or use "save as". I guess that sort a makes this file a template.

Either way, I would appreciate your wisdom on how to solve this dilema.

I have only poked around with macros and vba so be very specific.
Thank you kindly
 
G

Guest

OK, so a template does work!
Sorry to waste bit bucket space.

So many questions, so little time!
 
G

Guest

OK - I want to be a bit fancier now.

I have a template. I would like to force the file to be saved by the name it
a cell (J2). So, when they want to save the file, they just click on save or
save as, the template prompts them for a name, the name is already filled in
as the name in cell J2, they just confirm it.

Thank you for teaching me a lot and making me look good!
 
B

Bob Phillips

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Application.EnableEvents = False
Cancel = True
ThisWorkbook.SaveAs Worksheets("Sheet1").Range("J2").Value
Application.EnableEvents = True

End Sub


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
G

Guest

Bob, Thank you so much!

Can you help me specify the directory to save this file in?

In addition, if I save in "C:/MyForms/Range"J2".xls" what happens if the
directory doesn't exist? Will it prompt to make a directory?

Cheers!
P.S. I picked up O'Reilly's book on macros - so maybe there's hope I'll
learn this stuff. A lot of my problems are syntax - how to you name an
external file you want to open, how you specify cells in other workbooks or
worksheets. But I'm learning.
 
M

Marc

Well, why don't you just make the file read only? Then the only way to save
is "save as"...
 
G

Guest

Thank you, Marc -

But, as long as I already have a macro running, could someone tell me how to
disallow SAVE AS, this way, I know I will end up with the proper naming
conventions.

Also, could someone read the post above about specifying directories to SAVE
in?

I really appreciate all the help on this site!
Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top