Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to prevent overwriting of file ?

Hi, I have created a template in excel. Now a user would work on
that.. and do some work...BUT while saving, I dont want to all
overwrting the template file i.e the template woudl be named as say,
MyTemplate.xls, so as long user is trying to issue a save and is
working on MyTemplate.xls, I want to force Save As, rather than Save.

Please guide me.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default How to prevent overwriting of file ?

Hi

When you save your Template for the first time, On the Save as dialogue,
use the dropdown on Save as File type to Select Template (.xlt)

When a user clicks on the file to open it, a copy will open, as Book1, Book2
etc.
When they choose Save, they will be prompted to give a name in place of
Book1 etc.
Your Original Template will still be intact.

--
Regards
Roger Govier

wrote in message
...
Hi, I have created a template in excel. Now a user would work on
that.. and do some work...BUT while saving, I dont want to all
overwrting the template file i.e the template woudl be named as say,
MyTemplate.xls, so as long user is trying to issue a save and is
working on MyTemplate.xls, I want to force Save As, rather than Save.

Please guide me.
Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to prevent overwriting of file ?

Vow.. It works..Great , thanks...
Hey, but is there any way by which I can force a SaveAs when the file
being saved has some specific name, else just save ... ?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default How to prevent overwriting of file ?

Hi

The following code entered into the ThisWorkbook module could be used.

You will need to amend to suit your circumstances, and add some checks to
ensure the user doesn't add .xls to the end of the name they give etc., but
it should get you started

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim filename As String, oldname As String
oldname = ThisWorkbook.Name
Application.EnableEvents = False
entername:
filename = ""
filename = InputBox ("Enter a NEW Filename to save this file as")
filename = filename & ".xls"
If oldname = filename Then
MsgBox ("You have chosen the same name " & oldname & vbCr _
& " Choose something different")

GoTo entername
End If
ThisWorkbook.SaveAs filename
Application.EnableEvents = True
End Sub
--
Regards
Roger Govier

wrote in message
...
Vow.. It works..Great , thanks...
Hey, but is there any way by which I can force a SaveAs when the file
being saved has some specific name, else just save ... ?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to prevent overwriting of file ?

I Expected something like this only...
but why are u not using SaveAsUI for forcing a SaveAs ?
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
prevent cell overwriting connect4u Excel Worksheet Functions 1 December 22nd 09 01:28 PM
Prevent user from overwriting file peter.thompson[_45_] Excel Programming 5 January 14th 06 12:31 PM
prevent users from overwriting other users data [email protected] Excel Worksheet Functions 0 April 17th 05 08:18 PM
overwriting a file Jordan Shoderu Excel Programming 4 August 6th 04 11:46 AM
Overwriting a file automatically using saveas in a macro Sam Excel Programming 5 May 5th 04 04:01 AM


All times are GMT +1. The time now is 04:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"