Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Can date format be changed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francis Hookham - 01 Sep 2006 20:31 GMT
I have a number of paragraphs which start with the date in the format
05.09.2006
that is dd.mm.yyyy

Please can you write a macro to find dates in dd.mm.yyyy format
and change them to d mmm yy format, that is 5 Sep 06

Having seen how to do that, I take it that it would be straight forward to
change instead to ddd, d mmm yy (Tue, 5 Sep 06) or ddd, d mmmm yy (Tue, 5
September 06) if I wished.

Many thanks,

Francis Hookham
Doug Robbins - Word MVP - 01 Sep 2006 21:03 GMT
The following should do it

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
   Do While .Execute(FindText:="[0-9]{2}.[0-9]{2}.[0-9]{4}",
MatchWildcards:=True, Wrap:=wdFindContinue, Forward:=True) = True
   Selection.Text = Format(Mid(Selection.Text, 4, 2) & "/" &
Left(Selection.Text, 2) & "/" & Right(Selection.Text, 4), "d MMM yy")
   Loop
End With

You can get different formats by simply modifying the d MMM yy in the Format
function.
Signature

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

>I have a number of paragraphs which start with the date in the format
> 05.09.2006
[quoted text clipped - 10 lines]
>
> Francis Hookham
Francis Hookham - 01 Sep 2006 21:28 GMT
Fantastic - just right - I must try to understand the composition of do
loops, my upbringing has been self-help from the difficult early days of XL
macros and While/Wend is as far as I have got - anywhere in particular for
me to look on the net for do loops in depth?

Thank you very much

Francis Hookham

> The following should do it
>
[quoted text clipped - 24 lines]
>>
>> Francis Hookham
Doug Robbins - Word MVP - 02 Sep 2006 12:58 GMT
Just the visual basic help file.  That's my only reference.

Signature

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

> Fantastic - just right - I must try to understand the composition of do
> loops, my upbringing has been self-help from the difficult early days of
[quoted text clipped - 33 lines]
>>>
>>> Francis Hookham
Francis Hookham - 02 Sep 2006 14:05 GMT
Thanks - I must load VB Help onto this elderly desktop - normally I use the
new laptop which has everything on it but it's dead at present and I'm
limping! Fortunately it is under warranty.

One last request - just before your Do Loop runs to change all the dates
from dd.MM.yy to ddd, d MMM yy I should like to Copy the first date, which
comes at the beginning of the second paragraph, and Paste it into the first
paragraph in the format MMMM yy.

The first paragraph has nothing in it but I shall add in bold "Rotary Club
of Cambridge - Calendar from " followed by the MMMM yy

I am most grateful

Francis Hookham

> Just the visual basic help file.  That's my only reference.
>
[quoted text clipped - 35 lines]
>>>>
>>>> Francis Hookham
Francis Hookham - 04 Sep 2006 17:54 GMT
One last request - just before your Do Loop runs to change all the dates
from dd.MM.yy to ddd, d MMM yy I should like to Copy the first date, which
comes at the beginning of the second paragraph, and Paste it into the first
paragraph in the format MMMM yy.

The first paragraph has nothing in it but I shall add in bold "Rotary Club
of Cambridge - Calendar from " followed by the MMMM yy

I am most grateful

Francis Hookham

>> Just the visual basic help file.  That's my only reference.
>>
[quoted text clipped - 35 lines]
>>>>>
>>>>> Francis Hookham
Doug Robbins - Word MVP - 04 Sep 2006 18:24 GMT
Insert the following before the previous code:

Dim drange As Range
With ActiveDocument
   Set drange = .Paragraphs(2).Range
   drange.End = drange.Start + 10
   .Range.InsertBefore "Rotary Club of Cambridge - Calendar from " &
Format(Mid(drange, 4, 2) & "/" _
& Left(drange, 2) & "/" & Right(drange, 4), "MMMM yy")
   .Paragraphs(1).Range.Font.Bold = True
End With

Signature

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

> One last request - just before your Do Loop runs to change all the dates
> from dd.MM.yy to ddd, d MMM yy I should like to Copy the first date, which
[quoted text clipped - 47 lines]
>>>>>>
>>>>>> Francis Hookham
Francis Hookham - 04 Sep 2006 20:47 GMT
Thank you - just right after swapping round (as previously) to
Left/Mid/Right for UK format of d MMM yy

Francis Hookham

> Insert the following before the previous code:
>
[quoted text clipped - 59 lines]
>>>>>>>
>>>>>>> Francis Hookham
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.