Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorrect date format 1

Status
Not open for further replies.
Oct 12, 2005
204
GB
Hi,
We have recently upgraded from office 2000 to office 2010, all went fine but we have got one issue that I hope somebody can shed some light on and hopefully resolve...

We created quite a few documents in word 2000 with a footer that contains a date, format is dd/mm/yyyy but when we open the documents in word 2010 the date shows as mm/dd/yyyy, I've double checked all language settings and all are set to English ( U.K )so I'm not sure where its picking this date format up from. I can manually remove then readd the date and this gives the correct date format but there are lots of documents, so was hoping to find out why it's doing this and the best solution to resolve it.

Thanks in advance,

Mick.
 
The date format will be picked up from the Windows regional Date/Time settings. It seems you have these set to the US date format.

Cheers
Paul Edstein
[MS MVP - Word]
 
I can replicate this ... and it does seem to be a 'feature'
 
Hi,
Thanks for your suggestions

Genomon I had looked at that link but no joy I'm affraid...

Macropod Yes the first thing I checked, but this was all setup correctly..

Strongm, this is the conclusion I came to.... I suppose the only thing to do is manually change every document to show the correct date format.

Thanks again for your help.

Mick.
 
OK then, you could use Find/Replace to fix the formats, toggling the field code display for each document 'on' beforehand. Alternatively, you could use a macro:
Code:
Sub UpdateDates()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document, Fld As Field, Rng As Range
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  For Each Rng In wdDoc.StoryRanges
    For Each Fld In Rng.Fields
      Select Case Fld.Type
      Case wdFieldDate, wdFieldCreateDate, wdFieldPrintDate, wdFieldSaveDate
        If InStr(Fld.Code.Text, "@") = 0 Then
          Fld.Code.Text = Replace(Fld.Code.Text, "DATE", "DATE \@ " & Chr(34) & "DD/MM/YYYY" & Chr(34))
        End If
      End Select
    Next
  Next
  wdDoc.Close SaveChanges:=True
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Simply run the macro and point its browser to a folder containing the documents to be processed. Any that have any kind of date field without a formatting switch will have one in the 'DD/MM/YY' format applied.

Cheers
Paul Edstein
[MS MVP - Word]
 
Macropod,
You have certainly lived upto your name, amazing....

Thanks so much this will save lots of time correcting the dates.

Much appreciated.

Mick.
 
>I suppose the only thing to do is manually change every document to show the correct date format

No, I think this could be automated. If the date is a field - which i suspect that it is - then the following is the sort of thing that would fix it:

Code:
[blue]Public Sub FixFooter()
    Dim mySection As Section
    Dim myFooter As HeaderFooter
    
    For Each mySection In ActiveDocument.Sections
        For Each myFooter In mySection.Footers
            myFooter.Range.LanguageID = wdEnglishUK
            myFooter.Range.Fields.Update
        Next
    Next
End Sub[/blue]
 
AH - too slow. Although my testing indicated that the 'feature' actually changes the language applied to the footer section, which my code fixes, whilst macropod's changes the displayed date no matter what the language applied to the field
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top