![]() |
#1
|
|||
|
|||
![]()
Help!
Ok, so i'm working on a large project and am trying to figure out if what I want to do is even possible... First step: Is it possible to run a macro in Word that takes the current date, whatever it is when the document is opened, and add 7 days to that date? The date format would be mmmm d, yyyy. I have two points within my 23 page document where i need this to happen and it works when I run the macro but it always adds the date to wherever my cursor is as well, I need to turn that off as well. Now, i found out it's possible to run a macro that prompts the user to click "ok" or whatever i want at the opening of the document but I can't figure out how to tie that to the document to run the macro that I found. Here are the macro's that I'm currently using: To open a message: Private Sub Document_Open() 'run.macro MsgBox "Run Macro?", vbOKOnly, "Message" End Sub To add the date: Sub DATEPLUS7() Selection.TypeText Text:=Format(Date + 7, "mmmm d, yyyy") Dim myStoryRange As Range For Each myStoryRange In ActiveDocument.StoryRanges With myStoryRange.Find .Text = "[DATEPLUS7]" .Replacement.Text = Format(Date + 7, "mmmm d, yyyy") .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next myStoryRange End Sub |
Tags |
current date, macro, vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
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 |
![]() |
arkay | Mail Merge | 1 | 03-20-2012 11:50 PM |