fill in date field that automatically updates in template

E

EvieJean

I'm typing daily menus, can that date fields be formated to automatically
upday to the next day and date when I open the template again?
Tuesday - July 1, next template to automatically say Wednesday - July 2?
 
G

Graham Mayor

Hmmm. If the requirement is for the date to be incremented automatically by
one, each time a document is created from the template, then a combination
of techniques would be required, with the last used date held in an ini
file.

The following is a minor variation of a macro I posted a while back, that
will type the date at a bookmark location called MenuDate, incremented by
one each time the macro is run. The count is stored in a text file saved in
the Word startup folder. A second macro allows for the count to be simply
reset.

The main macro could be run as an autonew macro from the menu template in
which the bookmark has been added at the appropriate location.


Sub AddMenuDateToBookmark()
Dim SettingsFile As String
Dim Order As String

SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"MenuDate", "Order")
If Order = "" Then
Order = 0
End If
With Selection
.GoTo What:=wdGoToBookmark, _
name:="MenuDate"
.TypeText Text:=Format((Date + Order), "dddd d MMMM yyyy")
End With
Order = Order + 1
System.PrivateProfileString(SettingsFile, "MenuDate", _
"Order") = Order
End Sub


Sub ResetDateCount()
Dim SettingsFile As String
Dim Order As String
Dim sQuery As String
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"

Order = System.PrivateProfileString(SettingsFile, _
"MenuDate", "Order")
sQuery = InputBox("Re-set date count?" & vbCr & _
"Default setting will re-use the last used date" & vbCr & _
"Enter '0' to return to today's date", "Reset", Order - 1)
If sQuery = "" Then Exit Sub
Order = sQuery
System.PrivateProfileString(SettingsFile, "MenuDate", _
"Order") = Order
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

EvieJean

Thank you very much for this "fix" I think I'll wait until I'm experienced
enough to understand it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top