Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-22-2019, 09:45 PM
bluefate25 bluefate25 is offline Macro / VBA to run at document startup Windows 10 Macro / VBA to run at document startup Office 2010
Novice
Macro / VBA to run at document startup
 
Join Date: Sep 2019
Posts: 2
bluefate25 is on a distinguished road
Default

Thank you both for your responses! I have been very frustrated with getting this to work (having no experience with macros) so this has been truly helpful!




What I ended up writing to get this to work was the following:


Sub AutoOpen()

If MsgBox("Run Macro?", vbYesNo, "Message") = vbYes Then Call DATEPLUS7
End Sub


Sub DATEPLUS7()
Application.ScreenUpdating = False
Dim BmkRng As Range: Const BmkNm As String = "MyDate"
With ActiveDocument
If .Bookmarks.Exists(BmkNm) Then
Set BmkRng = .Bookmarks(BmkNm).Range
BmkRng.Text = Format(Date + 7, "mmmm d, yyyy")
.Bookmarks.Add BmkNm, BmkRng
End If
.Fields.Update
End With
Application.ScreenUpdating = True


End Sub


I'm sure I'll have more questions in the future
Reply With Quote
Reply

Tags
current date, macro, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro / VBA to run at document startup start a macro with command Line startup switches Fesazu Word 3 02-08-2018 12:15 AM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
Macro / VBA to run at document startup StartUP location ptmuldoon Word 2 05-12-2015 12:19 PM
Save As Macro using first line of document as document name redzan Word VBA 1 01-31-2015 09:24 PM
Macro / VBA to run at document startup Merge doc on startup arkay Mail Merge 1 03-20-2012 11:50 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:10 AM.


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