Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word & Insert Date (Help!!!)

Status
Not open for further replies.

lbb4ever

Programmer
Aug 31, 2001
8
US
Hi :)

Our company does mailing lists and basically uses the same mail merge template. The only thing that we need to physically change is the date of the letter, but we need to change the date for a few days into the future. However, changing the date has been known to be overlooked. I need to find a way to have a dialog box (or the like) open upon loading the template where the user can enter the appropriate date. I've tried macros and the vb editor (I'm stuck on how to load the user form with the document). Can anyone help?

Thanks in advance,
Laura
 
To have the date updated automatically everytime you use your template, simply go to Insert->Field... and select Date from the list. Set the format you want to use for the date, and press OK.

This will create a field in your document where the cursor is located that contains the current date.

NOTE: If you wish to use custom formatting, the format for Month is different than in Excel. To format you field as 17.08.2003, enter "dd.MM.yyyy" in the format field.

After this is done, the field(s) will update with the current date everytime you open the document. To update them manually, right click on the field and select "Update Field" from the pop-up menu.


Hope this helps!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Hi, Laura,

to get a macro to run when the document is opened, call the macro autoopen:

Code:
Sub autoopen()

    MyNiceForm.show

End Sub

Should the macro need to run when you create a new document using a template, call the macro autonew.

The line of code in there will show the form. Then you can put the rest of the programming behind the OK button in the userform.

A simpler way would be to do the following:

Code:
Sub autoopen()

    Dim oDate
    oDate = Inputbox("Type in the date ....")
    'Now jump to your bookmark or whatever and insert the contents of the variable oDate

End Sub


Carol, Berlin :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top