Can word insert a date automatically that is based on a previous date?

Hi experts,

I am wondering if I could open Word and have today's date automatically populate as it does now. But, could there be a placeholder further down the page that would insert a date based on the original date. Say 20 days later?

Using Office 2013.

Thanks.

Bert
LVL 1
Bert2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try

Regards
DatePlus20.docx
0
Bert2005Author Commented:
Hi Rgonzo1971,

I very much apologize for the delay. I am not sure if that is what I had in mind. I probably didn't describe it too well. And, I am sure it is something that would work with Excel but not Word.

I was hoping to be able to open a Word document, have it automatically insert today's date, which it does already, but then also add a date a few lines down that would always be 20 days later. I would then cut and paste it into the letter.

We make bills out of Word. So, we like to put the due date in the letter. And, it is always 20 days after today's date.

Thanks.

Bert
0
Bert2005Author Commented:
Hi Rgonzo,

Please keep in mind that if it can't be done, that is also an answer.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Rgonzo1971Commented:
Could you send a dummy of your file?
0
Bert2005Author Commented:
Final-Notice.docx

Just trying to insert a date where it is bolded that would automatically be 20 days after the heading date.
0
Rgonzo1971Commented:
See example

Regards
Final-NoticeV1.docx
0
Bert2005Author Commented:
I apologize. I don't think I am asking it correctly. The date of March 11, 2015 is five months after 10/16/2014 not 20 days. I can't tell if the day of 3.11.15 was typed in manually or derived automatically via Word using the 10.16.2014.

Sorry, I am not clear.
0
FlysterCommented:
Here's one way you can do that. Insert a bookmark where you want the date to appear. Name it DatePlus20. Now open the visual basic editor (alt+f11) and paste in this macro:

Sub AutoOpen()
  Selection.GoTo What:=wdGoToBookmark, Name:="DatePlus20"
  Selection.InsertBefore Format((Date + 20), "mm/dd/yyyy")
End Sub

You will have to save it as a macro-enabled document. Now every time this document is opened, it will add the date which is 20 day past the date it was opened. I tried to attach a working copy, but they don't recognize the .docm format.

Flyster
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rgonzo1971Commented:
HI,

I only used the wrong format for the date

see new example
Final-NoticeV2.docx
0
Bert2005Author Commented:
@Rgonzo1971 -- Thanks for your continued replies.

@Flyster -- That looks like a possibility. I will give it a shot and get back to you. Thanks.
0
Bert2005Author Commented:
Well, I tried everything as stated. I just couldn't get the bookmark to stick. I did use alt F11 for the editor. Anyway, I tried. I did save the document as a .docm. Is it possible to attach it here and change the extension to .doc?

Thanks.
0
FlysterCommented:
Try this. Go f11 and remove the ' from each line of code. Hope this works!
Final-Notice-AutoOpenRem.docx
0
FlysterCommented:
Saving it as a .docx removed the macro. Copy the above code and paste it into this document. It worked again on my end.
0
Bert2005Author Commented:
Hi Flyster,

OK, so I created one based on your instructions, but I have no way of testing it on a different date. Going "Back To The Future" didn't work so well -- changed the date on the client clock. I just realized that Michael J. Fox had the role of McFly in that movie, which is a really poor pun, but had to say it.

I am attaching a .png file (one that I believe it accepts), of my macro document. I do have a few questions though, if I may.

First, I was able to use the Bookmark thing, but I wasn't sure how to supply it with a placeholder, in other words, how would it know what to bookmark. I believe the intended us of a Bookmark would be to make it easy to go to certain sections of a long Word document, so you could likely just highlight an area. When I highlighted DatePlus20 or Date or something to put in the variable, it was inserted before the "placeholder." So, I ended up just inserting a small highlight in between both "bys." It seemed to work, but I am not sure. I then used the script you supplied.

So, there is the issue of am I letting the document know where to place the date correctly. There is also the issue that the date seems to be a different font, but I can't change it. Also, in the script, the format of the date is mm/dd/yyyy. How would I change that to Month dd, yyyy?
0
Bert2005Author Commented:
Of couirse, I forgot the attachment. I know I could edit the above, but I didn't want to take the chance.

Snippet
Finally, if this works, (big if with me), how does the macro tell the inserted date to use the header date as the one to go by? What if there just happened to already be another date in the body of the letter?
0
FlysterCommented:
You're using the Date function in your field code, which is the same thing the macro is using. So they're both the same date. The bookmark is placed between two spaces, one on each side. The code populates starting at the bookmark. With spaces on either side it the date fits nicely between the two "by's. To get the date format you want, change the second line of the code to this:

Selection.InsertBefore Format((Date + 20), "mmmm dd, yyyy")
0
Bert2005Author Commented:
Ok, I think we are finally on to something, e.g. it may be working. Geez, I had to change the code three times. Left in the / after mmmm, then forgot the comma after dd, then forgot a space after the comma. But, hey, live and learn. I am still trying to figure out if the font is different.

Then, again, when you receive a collection letter, you probably don't pay much attention to the font, lol.

So, here is my major question. You have the Word file sitting on the desktop. And, hopefully, somewhere else on the server. I used SharePoint, but that seemed to make things more difficult. Was great when using the versions.....

So, the document is saved with the Bookmark between the two bys. You open the document, type in the name, etc. (I will have to put in the auto-type fields or whatever). Different question though. Good one for a pointer. Anyway, now the document has the date in it. When you go to close it, should you close it and not save, thus returning it to the state with no names typed in and the bookmark only, or should you save it, so the calculated date is still saved. It would act as the bookmark, correct? Just wondering which would work best for the task I am trying to do.

Thanks for your help.
0
FlysterCommented:
If you save it, close it and then open it, the macro will put another date in front of the first. I may have taken your request, "insert a date automatically " a little too literally. Instead of making this an AutoOpen macro, which runs every time the document opens, you can make it a standard macro and run it when you want. Just change the top line to:

Sub InsertDate()

You can assign a keyboard shortcut to it by going to Word Options-Customize-Keyboard Shortcuts:Customize. Select the macro and then select the keys you want to use.
0
Bert2005Author Commented:
Thanks Flyster. That ought to do it.
0
FlysterCommented:
You're welcome. And I didn't have to expend 1.21 gigawatts to do it ! :)
0
Bert2005Author Commented:
Hi Flyster,

Are you still available to help a little? I changed the macro, but I still think I am doing something  wrong.

Thanks.

Bert
0
FlysterCommented:
Sure. Send me the changes.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.