Solved

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

Posted on 2014-09-30
23
114 Views
Last Modified: 2014-11-11
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
0
Comment
Question by:Bert2005
  • 11
  • 7
  • 4
23 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40353919
Hi,

pls try

Regards
DatePlus20.docx
0
 
LVL 1

Author Comment

by:Bert2005
ID: 40361796
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
 
LVL 1

Author Comment

by:Bert2005
ID: 40376199
Hi Rgonzo,

Please keep in mind that if it can't be done, that is also an answer.
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40376400
Could you send a dummy of your file?
0
 
LVL 1

Author Comment

by:Bert2005
ID: 40378804
Final-Notice.docx

Just trying to insert a date where it is bolded that would automatically be 20 days after the heading date.
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40379204
See example

Regards
Final-NoticeV1.docx
0
 
LVL 1

Author Comment

by:Bert2005
ID: 40385325
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
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 40385746
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
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40386020
HI,

I only used the wrong format for the date

see new example
Final-NoticeV2.docx
0
 
LVL 1

Author Comment

by:Bert2005
ID: 40392098
@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
 
LVL 1

Author Comment

by:Bert2005
ID: 40393519
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 22

Expert Comment

by:Flyster
ID: 40395968
Try this. Go f11 and remove the ' from each line of code. Hope this works!
Final-Notice-AutoOpenRem.docx
0
 
LVL 22

Expert Comment

by:Flyster
ID: 40395973
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
 
LVL 1

Author Comment

by:Bert2005
ID: 40395998
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
 
LVL 1

Author Comment

by:Bert2005
ID: 40396000
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
 
LVL 22

Expert Comment

by:Flyster
ID: 40396049
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
 
LVL 1

Author Comment

by:Bert2005
ID: 40396064
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
 
LVL 22

Expert Comment

by:Flyster
ID: 40396095
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
 
LVL 1

Author Comment

by:Bert2005
ID: 40401044
Thanks Flyster. That ought to do it.
0
 
LVL 22

Expert Comment

by:Flyster
ID: 40403179
You're welcome. And I didn't have to expend 1.21 gigawatts to do it ! :)
0
 
LVL 1

Author Comment

by:Bert2005
ID: 40435043
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
 
LVL 22

Expert Comment

by:Flyster
ID: 40436476
Sure. Send me the changes.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now