Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2023, 07:22 AM
gmaxey gmaxey is offline Run an ms word vba macro before a specific time Windows 10 Run an ms word vba macro before a specific time 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
  #2  
Old 11-13-2023, 08:45 PM
acmuller acmuller is offline Run an ms word vba macro before a specific time Windows 10 Run an ms word vba macro before a specific time Office 2010
Novice
Run an ms word vba macro before a specific time
 
Join Date: Nov 2023
Posts: 2
acmuller is on a distinguished road
Default Run an ms word vba macro before a specific time

Graham and Greg; Thanks for this code. I'll get back to you again after I give it a try.-- Charles
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to navigate to specific point in line (Word 97) Genericname1111 Word 13 10-06-2019 08:54 PM
Run an ms word vba macro before a specific time Macro to select multiple sentences that contain a specific word MauiTruss Word VBA 7 10-03-2018 03:46 PM
Executing a Word macro only after a certain date & time rdross51 Word VBA 4 07-07-2017 06:29 AM
Help with Macro to Save Word File as PDF in Specific Location ekimisme Word VBA 1 06-07-2017 10:40 PM
Run an ms word vba macro before a specific time Excel Macro finding a specific word ducky831 Excel Programming 3 09-17-2015 01:36 PM

Other Forums: Access Forums

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


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