macro to calculate a date in the future
Greg This is brilliant. However I'm still haveing trouble with it.
When I try to run it I get a "Type Mismatch" message box.
I copied and pasted the macro.
Could you tell me what I have done wrong.
"Greg Maxey" wrote:
Sally,
Not very elegant and assumes the date of the letter is in a bookmark
named "DOL" and the location of the due date is bookmarked "DD"
Sub Test()
Dim oRng As Range
Dim dateDOL As Date
Dim dateDD As Date
dateDOL = CDate(ActiveDocument.Bookmarks("DOL").Range.Text)
dateDD = DateAdd("d", 8, dateDOL)
Select Case Format(dateDD, "DDDD")
Case "Saturday"
dateDD = DateAdd("d", 2, dateDD)
Case "Sunday"
dateDD = DateAdd("d", 1, dateDD)
Case Else
'Do Nothing
End Select
Set oRng = ActiveDocument.Bookmarks("DD").Range
oRng.Text = dateDD
ActiveDocument.Bookmarks.Add "DD", oRng
End Sub
v&sr4JC wrote:
I would like to have a macro that would calculate a date in the future. I
need to include in my letters for work that a response is due within 8 days.
So 8 days from the date of my letter, I would like a toolbar macro that will
input the date, 8 days in the future but if that date falls on a weekend, it
would select Monday as the due date. Is this possible?
--
many thanks,
Sally
|