Saving templete / workbook to a specific drive / file...trying again

J

Johnnyboy5

The macro below works but... it’s a bit confusing for the end user in
that I does save the file name as A1 to the right drive / directory –
however it does show the end users it has done that.

It will also change it again if A1 is changed but its not clear to the
end user that the save has been done.

When the save as option is chosen in the file menu the save takes
place but in the Save As box it shows the previous file name etc.
Also if it’s a new sheet from a template it defaults to “Documents”
and I need it to default to the sheet in “my drive”

My approach to this problem might be all wrong.

What I want is to prevent the “end user” from messing up the original
sheet – but to be able to fill it in then save it with a name and file
number and leave the original un changed. Quite often they ignore the
“read only” use the form add the data and then save it over the
original before noticing what they have done.

I could use a FORM but the sheet is very complex (in the back ground)
and end users are OK with filling in their part of the sheet without
too much trouble – so a FORM is out.

NOTE – the end users are not very smart…

Thanks John

Thanks to Don Guillett for the macro below.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)


mydrive = "H:"
mydir = "Temp"
myname = Sheets("sheet1").Range("a1")
ms = mydrive & "\" & mydir & "\" & myname & ".xls"
ActiveWorkbook.SaveCopyAs Filename:=ms
End Sub
 
P

Per Jessen

Hi John

Add theese two lines to your macro:

Cancel=True
ActiveWorkbook.Saved=True

I would also add a message box to inform user that the workbook has
been saved:

msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")

Regards,
Per
 
J

Johnnyboy5

Hi John

Add theese two lines to your macro:

Cancel=True
ActiveWorkbook.Saved=True

I would also add a message box to inform user that the workbook has
been saved:

msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")

Regards,
Per

Thanks Per nearly there.

one issue - the very top of the Excel screen on the left hand side
still shows the original name.

john
 
J

Johnnyboy5

Hi John

Add theese two lines to your macro:

Cancel=True
ActiveWorkbook.Saved=True

I would also add a message box to inform user that the workbook has
been saved:

msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")

Regards,
Per

Oh. how can i save it as a template - as the macro runs before I can
save it as a template

John
 
N

norie

John

Why don't you use a template (xlt) workbook in the first place?

Then when the user opens it they will actually create a new workbook
based on the template.

They can then do whatever the need/want with the new workbook without
affecting the (original) template.
 
J

Johnnyboy5

John

Why don't you use a template (xlt) workbook in the first place?

Then when the user opens it they will actually create a new workbook
based on the template.

They can then do whatever the need/want with the new workbook without
affecting the (original) template.

Hi

because if they use a template its default save is to "Documents" and
I need the results saved to a different drive / folder. I am trying
to avoid them having to use a macro and that all the change of drive
stuff etc takes place in the back ground. Any ideas ?

John
 

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