At work I have password protected documents (I know the password). Each Day
Mon-Friday I need to add a date for the next day - except Friday when I need
to insert Mondays date. Is there a way to automate this so all I have to do
is click print when the document is opened? Not sure if this matters but, I
have about 70 different documents that I have to open and do this to everyday.
Thanks Wade
Hi Wade,
Yes, you can automate this. Here's some sample code to get you started:
Dim dDate As Date
Dim oRng As Range
Select Case Weekday(Date)
Case vbMonday, vbTuesday, vbWednesday, vbThursday
dDate = Date + 1
Case vbFriday
dDate = Date + 3
Case Else '''Sat. or Sun.
''' do nothing
End Select
Set oRng = ActiveDocument.Range
oRng.Collapse Direction:=wdCollapseEnd
oRng.InsertAfter Text:=vbCrLf & dDate
You have a lot of options for formatting your date. The last line above is
only one example. Here's another, very easy alternative:
oRng.InsertAfter Text:=vbCrLf & FormatDateTime(dDate, vbLongDate)
HTH,
Dave
> At work I have password protected documents (I know the password). Each
> Day
[quoted text clipped - 8 lines]
>
> Thanks Wade