Link to home
Start Free TrialLog in
Avatar of Bert2005
Bert2005Flag for United States of America

asked on

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
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try

Regards
DatePlus20.docx
Avatar of Bert2005

ASKER

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
Hi Rgonzo,

Please keep in mind that if it can't be done, that is also an answer.
Could you send a dummy of your file?
Final-Notice.docx

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

Regards
Final-NoticeV1.docx
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.
ASKER CERTIFIED SOLUTION
Avatar of Flyster
Flyster
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HI,

I only used the wrong format for the date

see new example
Final-NoticeV2.docx
@Rgonzo1971 -- Thanks for your continued replies.

@Flyster -- That looks like a possibility. I will give it a shot and get back to you. Thanks.
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.
Try this. Go f11 and remove the ' from each line of code. Hope this works!
Final-Notice-AutoOpenRem.docx
Saving it as a .docx removed the macro. Copy the above code and paste it into this document. It worked again on my end.
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?
Of couirse, I forgot the attachment. I know I could edit the above, but I didn't want to take the chance.

User generated image
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?
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")
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.
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.
Thanks Flyster. That ought to do it.
You're welcome. And I didn't have to expend 1.21 gigawatts to do it ! :)
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
Sure. Send me the changes.