View Single Post
 
Old 11-13-2023, 07:22 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Graham shows you a method to run you macro if you start word before 1100 a.m.



Here is a method to run your macro once per day. Regardless of the the time you start word. It uses the registry to store variables.


Code:
Option Explicit
Sub AutoExec()
  If GetSetting("DailyAutoRun", "Settings", "Date") = vbNullString Then SaveSetting "DailyAutoRun", "Settings", "Date", Format(Date, "MM/dd/yyyy")
  If CLng(CDate(GetSetting("DailyAutoRun", "Settings", "Date"))) <= CLng(Date) Then
    SaveSetting "DailyAutoRun", "Settings", "Date", Format(DateAdd("d", 1, Date), "MM/dd/yyyy")
    MyMacro
  End If
lbl_Exit:
  Exit Sub
End Sub
Sub MyMacro()
  MsgBox "Test"
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote