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 / January 2007

Tip: Looking for answers? Try searching our database.

Loop thru files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mickey - 31 Jan 2007 17:10 GMT
Hi,
I've done this before but seem to be doing something wrong now.  I want
change the date in a bunch of docs.  
I'm using the following code.  It changes it in the first doc but doesn't
move to the next.

For Each aDoc In Documents
 
       With Selection.Find
       .Text = "01/29/07"
       .Replacement.Text = "03/01/07"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .Execute Replace:=wdReplaceAll
   End With
 
   ActiveDocument.Save
   ActiveDocument.Close
   Next aDoc

Thanks,
Mickey
Jonathan West - 31 Jan 2007 18:26 GMT
> Hi,
> I've done this before but seem to be doing something wrong now.  I want
[quoted text clipped - 19 lines]
> Thanks,
> Mickey

Change this

       With Selection.Find

to this

       With aDoc.Range.Find

and this

   ActiveDocument.Save
   ActiveDocument.Close

to this

   aDoc.Save
   aDoc.Close

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Doug Robbins - Word MVP - 31 Jan 2007 18:31 GMT
See the article "Find & ReplaceAll on a batch of documents in the same
folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

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

> Hi,
> I've done this before but seem to be doing something wrong now.  I want
[quoted text clipped - 19 lines]
> Thanks,
> Mickey

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.