VBA & Macro Problems

Automatically Convert Short Dates to Long Dates in Microsoft Word

Chanuka GeekiyanageChanuka Geekiyanage Nov 13, 2026 868 views

Question details

Convert existing short dates such as 17/12/20 into long dates throughout a Microsoft Word document using a VBA macro.

Automatically Convert Short Dates to Long Dates in Microsoft Word
Product
Microsoft Word
Device & OS
not provided
Scenario
A large document contains slash-separated day/month/year dates that need a consistent long-date format.
Observed behavior
Word does not automatically convert every typed short date into a long date. A macro can find, validate, and replace matching dates.
Before you start

Use a desktop version of Word that supports VBA, and confirm that the source dates use day/month/year order. The macro below interprets two-digit years as 2000–2099 and produces dates such as 17 December 2020 without ordinal suffixes.

Solution 1Recommended

Convert day/month/year dates with a Word VBA macro

Use this method to convert many existing dates in the main document text without replacing them individually.

Checking a slash-separated string with IsDate and converting it with CDate can depend on regional settings. This macro instead parses the day, month, and year explicitly, builds a date with DateSerial, and checks its components before applying Format.

The macro runs on demand; it does not reformat dates as you type. It searches the main document text, including tables, but does not separately process headers, footers, footnotes, or text boxes.

1
Open the VBA editor

In Word, open Developer > Visual Basic. If Developer is hidden on Windows, go to File > Options > Customize Ribbon, select Developer, and click OK.

2
Insert a module in the document

In the VBA editor's Project Explorer, select your document's project, then choose Insert > Module. This creates a standard module for the conversion macro.

3
Paste the conversion macro

Paste this code into the module: Sub ConvertShortDatesToLongDates() Dim doc As Document Dim r As Range Dim parts() As String Dim dayNum As Long, monthNum As Long, yearNum As Long Dim dateValue As Date Dim validYear As Boolean Set doc = ActiveDocument Set r = doc.Content With r.Find .ClearFormatting .Text = "[0-9]{1,2}/[0-9]{1,2}/[0-9]{2,4}" .MatchWildcards = True .Forward = True .Wrap = wdFindStop .Format = False End With Do While r.Find.Execute parts = Split(r.Text, "/") dayNum = CLng(parts(0)) monthNum = CLng(parts(1)) yearNum = CLng(parts(2)) validYear = False If Len(parts(2)) = 2 Then yearNum = 2000 + yearNum validYear = True ElseIf Len(parts(2)) = 4 Then validYear = (yearNum >= 100 And yearNum <= 9999) End If If validYear And dayNum >= 1 And dayNum <= 31 _ And monthNum >= 1 And monthNum <= 12 Then dateValue = DateSerial(yearNum, monthNum, dayNum) If Day(dateValue) = dayNum _ And Month(dateValue) = monthNum _ And Year(dateValue) = yearNum Then r.Text = Format(dateValue, "d mmmm yyyy") End If End If r.Collapse wdCollapseEnd r.End = doc.Content.End Loop End Sub

4
Save and run the macro

Return to Word and use File > Save As to save the document as Word Macro-Enabled Document (*.docm) if you want to retain the macro. Open Developer > Macros, select ConvertShortDatesToLongDates, and click Run. Enable macros only if you trust the document and its code.

5
Review the converted dates

Check representative dates in the document: 17/12/20 should become 17 December 2020, while 31/02/20 should remain unchanged. Review slash-separated numbers and dates embedded in longer strings, because the search pattern does not enforce standalone date boundaries. Month names follow the language or regional settings used by VBA.

Convert day/month/year dates with a Word VBA macro
Long dates are not ordinal dates: The format d mmmm yyyy produces 17 December 2020, not 17th December 2020. Adding st, nd, rd, or th requires additional VBA logic, including exceptions for 11th, 12th, and 13th.
Free Microsoft Office alternative

Edit your converted Word documents in WPS Writer

After completing the VBA conversion in Microsoft Word, use WPS Writer as a free, lightweight alternative for everyday document editing. Its familiar interface and support for Word formats make migration straightforward; it is not a fix for Word VBA execution.

Review and edit long-date text after conversion in Microsoft Word.Open and save Microsoft Word .doc and .docx formats.Use a familiar document-editing interface with common formatting tools.Move everyday editing tasks to a free, lightweight Office alternative.
microsoft office alternative - wps office

Frequently Asked Questions

Will this macro turn 17/12/20 into 17th December 2020?

No. Format(dateValue, "d mmmm yyyy") produces 17 December 2020. To include an ordinal suffix, extend the VBA code with a suffix function that handles st, nd, rd, and th, including the 11–13 exceptions.

How does the macro interpret dates such as 03/04/20?

It always uses day/month/year order, so 03/04/20 becomes 3 April 2020. Two-digit years are interpreted as 2000–2099. Do not run this version on mixed day/month/year and month/day/year data without resolving the ambiguity first.

Why not just use IsDate to validate every match?

IsDate applied to a date string can depend on regional settings, so 17/12/20 may not be recognized in a month/day/year environment. Parsing the components explicitly avoids that ambiguity. The macro also checks the resulting DateSerial components because DateSerial can roll invalid dates into the following month.

Can I run the macro in Word for the web?

No. Open the document in desktop Word, then use Developer > Visual Basic to add the code and Developer > Macros to run it. Word for the web does not run VBA macros.

Does the macro convert dates in headers and footnotes?

Not in this version. It searches ActiveDocument.Content, which covers the main document text and tables. Headers, footers, footnotes, and text boxes require additional VBA code to search their separate story ranges.