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 / March 2008

Tip: Looking for answers? Try searching our database.

Change date field to createdate

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sammy - 05 Mar 2008 17:07 GMT
Hi,

Yesterday I searched for and finally found a macro that would go through a
folder and change the date fields to createdate fields.   Now I can't find
that post!  Can anyone help me?  

Many thanks
Jean-Guy Marcil - 05 Mar 2008 19:55 GMT
> Hi,
>
> Yesterday I searched for and finally found a macro that would go through a
> folder and change the date fields to createdate fields.   Now I can't find
> that post!  Can anyone help me?  

Try ythis page:
  http://word.mvps.org/faqs/macrosvba/BatchFR.htm
Sammy - 05 Mar 2008 20:19 GMT
Well, I love this macro and I'm going to keep it for future reference but I
don't think I can search for a date field and replace with a createdate
field, the find and replace dialog didn't allow for that.

Thank you for your help.

> > Hi,
> >
[quoted text clipped - 4 lines]
> Try ythis page:
>    http://word.mvps.org/faqs/macrosvba/BatchFR.htm
Jean-Guy Marcil - 05 Mar 2008 20:49 GMT
> Well, I love this macro and I'm going to keep it for future reference but I
> don't think I can search for a date field and replace with a createdate
> field, the find and replace dialog didn't allow for that.

You can add code to toggle the display of field codes in the document, and
then you can use the find/replace to replace field code with other field
code...
Sammy - 05 Mar 2008 21:58 GMT
That's so smart!  Thanks a lot.

> > Well, I love this macro and I'm going to keep it for future reference but I
> > don't think I can search for a date field and replace with a createdate
[quoted text clipped - 3 lines]
> then you can use the find/replace to replace field code with other field
> code...
Graham Mayor - 06 Mar 2008 10:50 GMT
The batch macro you cannot find may have been

Sub BatchFixDates()
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document
Dim iFld As Integer
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
   .Title = "Select Folder containing the documents to be modifed and click
OK"
   .AllowMultiSelect = False
   .InitialView = msoFileDialogViewList
   If .Show <> -1 Then
       MsgBox "Cancelled By User"
       Exit Sub
   End If
   PathToUse = fDialog.SelectedItems.Item(1)
   If Right(PathToUse, 1) <> "\" Then PathToUse = PathToUse + "\"
End With

If Documents.Count > 0 Then
   Documents.Close Savechanges:=wdPromptToSaveChanges
End If
myFile = Dir$(PathToUse & "*.do?")

While myFile <> ""
Set myDoc = Documents.Open(PathToUse & myFile)
ActiveWindow.View.ShowFieldCodes = True
For iFld = ActiveDocument.Fields.Count To 1 Step -1
   With ActiveDocument.Fields(iFld)
       If .Type = wdFieldDate Then
           .Code.Text = Replace(.Code.Text, "DATE", "CREATEDATE")
           .Update
       End If
   End With
Next iFld
ActiveWindow.View.ShowFieldCodes = False
myDoc.Close Savechanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub

which I have posted a couple of times recently.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> That's so smart!  Thanks a lot.
>
[quoted text clipped - 6 lines]
>> document, and then you can use the find/replace to replace field
>> code with other field code...
fumei - 05 Mar 2008 20:52 GMT
Dim oField As Field
For Each oField In ActiveDocument.Fields
  If oField.Type = 31 Then
     oField.Select
     Selection.Fields(1).Delete
     ActiveDocument.Fields.Add Range:=Selection.Range, Type:=21
  End If
Next

will change DATE fields (Type 31) to CREATEDATE fields (Type 21)

>Well, I love this macro and I'm going to keep it for future reference but I
>don't think I can search for a date field and replace with a createdate
[quoted text clipped - 7 lines]
>> Try ythis page:
>>    http://word.mvps.org/faqs/macrosvba/BatchFR.htm
Sammy - 05 Mar 2008 21:58 GMT
Thank you for your time

> Dim oField As Field
> For Each oField In ActiveDocument.Fields
[quoted text clipped - 18 lines]
> >> Try ythis page:
> >>    http://word.mvps.org/faqs/macrosvba/BatchFR.htm

Rate this thread:






 
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.