Peg needed some help with Outlook:
I send out work schedules to staff through email. Is there any way to use a "date picker" (such as in Word or Excel) in the body of the email to minimize errors with the day and date? For example, if I type 3/11/16, want it to change the format to Thursday, March 11, 2016. I use Outlook 2010 or 2013. We do not use an Exchange server; all of the recipients will use personal emails (not our company email) and use a variety of email clients. Is there an addin that would help me? I don't know how to use VBA coding very well, but am willing to try. Any suggestions would be appreciated.
A solution that works in all clients is difficult but there might be Windows macro programs that can do this.
The macro below works in an open message; you need to position the cursor in front of the date then run the macro. It selects the text between the cursor and the next space, copies it to the clipboard and converts it to long date format before inserting it in place of the date you typed. If you need to convert multiple dates within a message, you can use RegEx to search the message for short dates.
You need to have a space after the date but it will accept the common short date formats: 3/10/16, 3/10, or the full short date 3/10/2016. If you type a character at the end of the date, such as 3/16:, change the Extend Character value in the code.
The format that is pasted in can be tweaked as needed. Examples:
objSel = Format(myDate, "dddd, mmmm d, yyyy") returns Monday, April 11, 2016
objSel = Format(myDate, "ddd, mmm-d-yyyy ") returns Mon, Jul-11-2016 and adds a space at the end
Note, you will need to have a reference to the MSForms and Word library in Tools, References. If the Microsoft Forms 2.0 Object Library is not listed in the references dialog, click Browse and paste C:\Windows\System32\FM20.dll or C:\Windows\FM20.dll as a reference.
Paste the macro into a module and create a button for it on the ribbon. See "How to use Outlook's VBA Editor" for screenshots.
Sub CopyPasteDate() On Error Resume Next Dim objItem As Object Dim objInsp As Outlook.Inspector Dim objWord As Word.Application Dim objDoc As Word.Document Dim objSel As Word.Selection Dim myDate As Date Dim DataObj As MSForms.DataObject Set DataObj = New MSForms.DataObject Set objItem = Application.ActiveInspector.CurrentItem Set objInsp = objItem.GetInspector Set objDoc = objInsp.WordEditor Set objWord = objDoc.Application Set objSel = objWord.Selection With objSel .Collapse .Extend Character:=" " End With objSel.Copy DataObj.GetFromClipboard myDate = DataObj.GetText(1) objSel = Format(myDate, "ddd, mmm-d-yyyy ") objSel.Move unit:=wdCharacter, Count:=1 Set objItem = Nothing Set objInsp = Nothing Set objDoc = Nothing Set objWord = Nothing Set objSel = Nothing End Sub
How to use macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor