Reputation: 4216
We send out a daily email using Outlook that contains the work week and day in the format of WW.D Our work week starts on Monday, so like today would be 50.2 How can I add this using VBA?
Sub MakeItem()
Dim objMail As MailItem
Set newItem = Application.CreateItemFromTemplate("C:\Users\Update.oft")
' Work week number
WW = 50.2
' Setup Subject replacing the <SHIFT>
newItem.Subject = Replace("<WorkWeek> Shift Passdown ", "<WorkWeek>", WW)
newItem.Display
Set newItem = Nothing
End Sub
Upvotes: 1
Views: 3862
Reputation: 35318
Try this:
WW = Format(Now, "ww") & "." & Weekday(Now, vbMonday)
The "Format" function returns an expression from a string formatted with the provided "format" argument (ww
in this case, which returns the week of the year) and the Weekday()
function returns the numbered day of the week where the first day is a VBDayOfWeek
enumeration provided as the second argument (vbMonday
in this case).
Upvotes: 2