Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-06-2017, 09:56 PM
rdross51 rdross51 is offline Executing a Word macro only after a certain date & time Windows 7 32bit Executing a Word macro only after a certain date & time Office 2010 32bit
Advanced Beginner
Executing a Word macro only after a certain date & time
 
Join Date: Feb 2015
Location: Abu Dhabi
Posts: 45
rdross51 is on a distinguished road
Default Executing a Word macro only after a certain date & time


I have the need to run a Word 2013 macro, but only after a certain date & time. I know you can do this in Excel but I cannot figure out if this can be done in Word. Any ideas?
Reply With Quote
  #2  
Old 07-07-2017, 01:32 AM
gmayor's Avatar
gmayor gmayor is offline Executing a Word macro only after a certain date & time Windows 10 Executing a Word macro only after a certain date & time Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It guess it depends what it is that the macro is supposed to do. You could check the date whenever Word is started and you can check the date when a document or global template is opened and perform some process.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-07-2017, 02:42 AM
rdross51 rdross51 is offline Executing a Word macro only after a certain date & time Windows 7 32bit Executing a Word macro only after a certain date & time Office 2010 32bit
Advanced Beginner
Executing a Word macro only after a certain date & time
 
Join Date: Feb 2015
Location: Abu Dhabi
Posts: 45
rdross51 is on a distinguished road
Default

I guess I should have been more specific. I am in charge of company templates. An upcoming project is going to require updated templates but those templates cannot be put in place until after the project has officially started. I am going to be out of office at this time and unable to to upload the new files, therefore I want to develop and automatic file copy based on a chosen input date. Please keep in mind that I am a novice and only have a rudimentary understanding of VBA.
Reply With Quote
  #4  
Old 07-07-2017, 04:15 AM
gmayor's Avatar
gmayor gmayor is offline Executing a Word macro only after a certain date & time Windows 10 Executing a Word macro only after a certain date & time Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
See attached example
Attached Files
File Type: dotm OutOfDate.dotm (24.7 KB, 8 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 07-07-2017, 06:29 AM
rdross51 rdross51 is offline Executing a Word macro only after a certain date & time Windows 7 32bit Executing a Word macro only after a certain date & time Office 2010 32bit
Advanced Beginner
Executing a Word macro only after a certain date & time
 
Join Date: Feb 2015
Location: Abu Dhabi
Posts: 45
rdross51 is on a distinguished road
Default

Thanks. That should work.
Reply With Quote
Reply



Similar Threads
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
Executing a Word macro only after a certain date & time Date & time stamp problems in Word XP Scotfan Word 3 03-09-2016 09:45 AM
Executing a Word macro only after a certain date & time Shift Excel Cell after executing a macro for second time LearningMacro Excel Programming 2 01-08-2015 03:05 PM
Executing a Word macro only after a certain date & time Word form w/ autopopulated date/time Dendalee Word 1 10-24-2012 11:40 PM
Executing a Word macro only after a certain date & time need help with macro date and time for dispatch sheets Jamesb8488 Word 1 04-28-2011 02:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft