Fix Incorrect Dates Imported from Word into Excel VBA
Question details
Import dates from a converted Word document into Excel without swapping the day and month.

- Product
- Microsoft Excel VBA and Microsoft Word
- Device & OS
- not provided
- Scenario
- A user extracts date text from a PDF converted to Word and transfers it to an Excel worksheet with VBA.
- Observed behavior
- Ambiguous dates such as 4/1/2006 can be interpreted with the day and month reversed because of regional date settings.
Confirm whether the source dates use month/day/year or day/month/year; an ambiguous value alone cannot establish the intended order. Open the converted Word document and identify the table cell or other location containing the date.
Parse the Word date explicitly with Excel VBA
Use this approach when the source date order is known and Excel may interpret pasted text according to different regional settings.
The example reads a date in month/day/year order from the first cell of the first table in the active Word document and writes a real date to Sheet1!C18. Change the source and destination references to match your files.
DateSerial constructs the date from separate year, month, and day values. The validation check rejects dates that DateSerial would otherwise roll into another month.
Open the source document in Word and the destination workbook in Excel. In Excel, press Alt+F11, then select Insert > Module.
Paste this code into the module. It assumes the source text uses M/D/YYYY and that Word is already running: Sub ImportWordDate() Dim doc As Object, ws As Worksheet Dim textDate As String, parts As Variant Dim m As Long, d As Long, y As Long Dim result As Date On Error GoTo ImportError Set doc = GetObject(, "Word.Application").ActiveDocument Set ws = ThisWorkbook.Worksheets("Sheet1") textDate = doc.Tables(1).Cell(1, 1).Range.Text textDate = Trim$(Replace(Replace(textDate, Chr$(13), ""), Chr$(7), "")) parts = Split(textDate, "/") If UBound(parts) <> 2 Then Err.Raise 5 If Not IsNumeric(parts(0)) Or Not IsNumeric(parts(1)) Or Not IsNumeric(parts(2)) Then Err.Raise 5 If Len(parts(2)) <> 4 Then Err.Raise 5 m = CLng(parts(0)): d = CLng(parts(1)): y = CLng(parts(2)) If y < 100 Or y > 9999 Then Err.Raise 5 result = DateSerial(y, m, d) If Year(result) <> y Or Month(result) <> m Or Day(result) <> d Then Err.Raise 5 ws.Range("C18").Value = result ws.Range("C18").NumberFormat = "mm/dd/yyyy" Exit Sub ImportError: MsgBox "Could not import the date. Check the source, date order, and worksheet name." End Sub
If the Word text uses D/M/YYYY instead, change the assignments to d = CLng(parts(0)) and m = CLng(parts(1)). For a day-first display, change the NumberFormat line to "dd/mm/yyyy".
In the VBA editor, place the cursor inside ImportWordDate and press F5. Check Sheet1!C18 against the original PDF, including a date where the day is greater than 12 if one is available.
Review Word Documents and Spreadsheets with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with Word documents and Excel spreadsheets. Its file compatibility makes it easy to move existing documents into your workflow. It does not repair an Excel VBA macro, and macro support can vary by edition and platform.

Frequently Asked Questions
Why does Excel change 4/1/2006 to 1/4/2006?
The text is ambiguous: it can mean April 1 or January 4. Excel may interpret pasted text using regional settings that differ from the source date order. Parse the original text according to its known order before writing it to a cell.
Will changing the cell format fix an incorrect date?
No. Use Range("C18").NumberFormat to control the display, but use the original source text and DateSerial to reconstruct a date whose day and month were already swapped.
What if the date is not in a Word table?
Replace doc.Tables(1).Cell(1, 1).Range.Text with a reference to the Word range containing the date. Make sure the extracted text contains only the date before splitting it on the separator.
Why should I avoid relying on ActiveCell when finding the destination?
ActiveCell can change as the user or macro selects another cell. Use an explicit worksheet and range, such as ws.Range("C18"), or qualify a Find operation with the intended worksheet range.




