Want all dates in row of a table formatted alike.

E

emilydoggy

I have a table created in Microsoft Word.

One column of the table contains dates of varying formats:
25-Mar-2005
03/25/05
March 25, 2005.

I would like to batch donvert the column of dates so that they all use the
the same format.

Thanks.
 
A

Anne Troy

Sorry, Em. Word doesn't support "date formats". Try copying them into Excel,
then formatting, then bringing back to Word. But I'm not sure that'll work
either.
*******************
~Anne Troy

www.OfficeArticles.com
 
J

Jay Freedman

I have a table created in Microsoft Word.

One column of the table contains dates of varying formats:
25-Mar-2005
03/25/05
March 25, 2005.

I would like to batch donvert the column of dates so that they all use the
the same format.

Thanks.

You may be able to use a macro like this (see
http://www.gmayor.com/installing_macro.htm if needed):

Sub ReformatDates()
Dim oCell As Cell
Dim oRg As Range

' adjust the table and column indexes as needed...
For Each oCell In ActiveDocument.Tables(1).Columns(2).Cells
Set oRg = oCell.Range
oRg.MoveEnd wdCharacter, -1
With oRg
If IsDate(.Text) Then
' adjust the formatting string as needed...
.Text = Format(CDate(.Text), "MM/dd/YYYY")
End If
End With
Next oCell
End Sub
 
J

Jean-Guy Marcil

Anne Troy was telling us:
Anne Troy nous racontait que :
Sorry, Em. Word doesn't support "date formats". Try copying them into

Sure it does, ever heard of Insert > Date and Time... ? Have you seen how
many formats are available there? They are even language specific.
Excel, then formatting, then bringing back to Word. But I'm not sure
that'll work either.

I would suggest that you try out simple stuff like this instead of
recommending it untested.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Doug Robbins

Dim i As Long, j As Long, drange As Range, dtable As Table
Set dtable = Selection.Tables(1)
j = Selection.Information(wdEndOfRangeColumnNumber)
For i = 2 To dtable.Rows.Count
Set drange = dtable.Cell(i, j).Range
drange.End = drange.End - 1
drange.Text = Format(drange.Text, "dddd, MMMM d, yyyy")
Next i


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jean-Guy Marcil

Doug Robbins was telling us:
Doug Robbins nous racontait que :
Dim i As Long, j As Long, drange As Range, dtable As Table
Set dtable = Selection.Tables(1)
j = Selection.Information(wdEndOfRangeColumnNumber)
For i = 2 To dtable.Rows.Count
Set drange = dtable.Cell(i, j).Range
drange.End = drange.End - 1
drange.Text = Format(drange.Text, "dddd, MMMM d, yyyy")
Next i

Thanks Doug, I hadn't answered because Jay already had before I even posted
my message.
I guess it will reinforce the message if two versions are available!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Doug Robbins

Yes, I didn't see Jay's post until after I had posted my method.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top