![]() |
#4
|
||||
|
||||
![]()
The short answer is no. You cannot delete or rename an open file and the file would have to be open in order to run the macro. The best solution I can think of is to put the new templates somewhere the users can access them and add the following code to the ThisDocument module of each old template (change the due dates as appropriate) and save as macro enabled templates. Users will not then be able to open the template or create new documents from it from that date, but would see a message instead.
Code:
Option Explicit Private Sub Document_New() If Format(Date, "yyyymmdd") >= Format("07/07/2017", "yyyymmdd") Then MsgBox "The template has expired, please download the latest version from 'somewhere'" ActiveDocument.Close End If lbl_Exit: Exit Sub End Sub Private Sub Document_Open() If Format(Date, "yyyymmdd") >= Format("07/07/2017", "yyyymmdd") Then MsgBox "The template has expired, please download the latest version from 'somewhere'" ThisDocument.Close End If lbl_Exit: Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
OneNote on Android phone View Tags? Enter Date, Time, Date & Time | DrTwinkyEsq | OneNote | 0 | 03-27-2017 07:54 PM |
![]() |
Scotfan | Word | 3 | 03-09-2016 09:45 AM |
![]() |
LearningMacro | Excel Programming | 2 | 01-08-2015 03:05 PM |
![]() |
Dendalee | Word | 1 | 10-24-2012 11:40 PM |
![]() |
Jamesb8488 | Word | 1 | 04-28-2011 02:54 PM |