+ Reply to Thread
Results 1 to 4 of 4

A macro to stop a workbook from being saved if it has certain file name. e.g. 'Blank Doc

  1. #1
    Registered User
    Join Date
    05-19-2016
    Location
    Australia, Tasmania
    MS-Off Ver
    MS Office 2010
    Posts
    16

    A macro to stop a workbook from being saved if it has certain file name. e.g. 'Blank Doc

    Hi all,


    I have a blank data workbook which is used to create a new workbook once a date has been entered. Can I prevent anyone from saving the blank workbook with a macro?

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: A macro to stop a workbook from being saved if it has certain file name. e.g. 'Blank D

    English is a wonderful language - Ambiguities all over the place.

    Do you mean:
    • Using a macro to prevent saving any workbook if all the cells are blank.
    or
    • Prevent saving a workbook if it is blank and contains macros

    ...?

    Pedantic, I know but there's a difference. And then there's your title, "stop a workbook from being saved if it has certain file name" - which is not mentioned in your post.

    Regardless, I think you want to consider saving your file as a Template. That can contain code to prevent the workbook being saved if all the cells are blank plus the users will not normally save a template as a template so it will have to be renamed.

    Confused yet?

  3. #3
    Registered User
    Join Date
    05-19-2016
    Location
    Australia, Tasmania
    MS-Off Ver
    MS Office 2010
    Posts
    16

    Re: A macro to stop a workbook from being saved if it has certain file name. e.g. 'Blank D

    Hi cytop,

    Thank you for your reply.

    I can see how someone could be confused on what I was asking for as my post was poorly written with very little info.
    I'll have a second attempt in explaining what I meant.
    We have a template data workbook called “sales data”, this workbook is used to collect information from other workbooks and outside sources. But before any information is meant to be entered and saved in this workbook the user needs to input the current date (21/06/2016) in a particular cell and select the “create new day” button. This button opens the save as function and saves a new workbook called “sales data 210616”.
    The issue I am having is that some users entering data and are saving over the original template before enter a date and selecting the “create new day” button.
    I was wondering is it possible to stop the workbook “sales data” from being saved but not the newly create workbook “sales data 210616”.

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: A macro to stop a workbook from being saved if it has certain file name. e.g. 'Blank D

    Goes back to my original answer - save the workbook as a template.

    When a template is loaded it is given the next default name (Book1, Book2...) so when saved it will be saved as a workbook, not the template.

    You can then include simple code to check a cell has a value before saving and take what action you want - or even save the workbook with the correct name as soon as a user enters a date in a particular cell - or pre-populate the cell with the date when loaded - imagination can run riot...

    I know it turns your logic upside down, but it a lot simpler than using a 'standard' workbook as a 'template' and gets rid of all the hassle preventing the users overwriting your 'template'.

    Just about the only procedural change your users will need to make is instead of opening a workbook, they open a blank workbook based on a template.
    Last edited by cytop; 05-25-2016 at 04:57 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Want auto-gen number in template workbook to stop working when saved to normal workbook
    By tjamestx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-24-2014, 02:56 PM
  2. [SOLVED] Macro to stop workbook being saved
    By bouncingbudha in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-01-2013, 02:35 PM
  3. [SOLVED] Opening Saved File also Opens Blank Workbook
    By msawyer in forum Excel General
    Replies: 2
    Last Post: 05-13-2013, 07:00 PM
  4. sequential numbering macro - how to stop it increasing when document is saved??
    By mansfieldchris in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-07-2011, 04:55 PM
  5. [SOLVED] stop opening a blank workbook at start up
    By km in forum Excel General
    Replies: 1
    Last Post: 01-18-2006, 03:40 PM
  6. I ACCIDENTIALLY SAVED A BLANK PAGE OVER A FILE HOW DO I GO BACK T
    By emily in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-24-2005, 01:15 PM
  7. [SOLVED] I just saved over a workbook file I NEED. Can I get it back?
    By not to smart in forum Excel General
    Replies: 2
    Last Post: 09-12-2005, 08:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1