Solved

Mutilple word document changes

Posted on 2011-09-28
4
189 Views
Last Modified: 2012-05-12
hi everyone,
does anyone know of a way to change a footer within hundreds of word documents. I need to apply a address change to hundreds of word documents. I was hoping not to open each one at a time to do this.
Does this make sense?
the original documents were created with a set letterhead.

cheers
0
Comment
Question by:RodneyFirmer
  • 2
  • 2
4 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
You will have to Open them, but not manually.

You could put them in single folder, and run a macro like this
Sub EditDocs()
    Dim strFolder As String
    Dim strFile As String
    Dim doc As Document
    Dim sec As Section
    Dim ftr As HeaderFooter
    
    strFolder = "C:\MyFolder"
    strFile = Dir$(strFolder & "\*.doc*")
    Do Until strFile = ""
        Set doc = Documents.Open(strFolder & "\" & strFile)
        For Each sec In doc.Sections
            For Each ftr In sec.Footers
                ftr.Range.Text = "My New Company"
            Next ftr
        Next sec
        doc.Close wdSaveChanges
        strFile = Dir
    Loop
End Sub

Open in new window

0
 

Author Comment

by:RodneyFirmer
Comment Utility
Thanks i haven't time to try this, the problem is also many documents within multiple folder structures.

Is there anyway of preventing this problem in the future.
cheers
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
Comment Utility
It would be quicker than doing each one manually,

If you expect to find some time in the near future, it might be worth us modifying the code to recurse down the folder structure, but of course there would need to be some test to see if the document is relevant, e.g. by doing a Find and Replace instead of just setting the text.

Future avoidance would depend on the way that the document files are used. If you are just want to distribute printouts, you could have the text somewhere external to the document, but accessible to you; for instance as an Autotext entry in a the document's template and displayed in an Autotext field.
0
 

Author Closing Comment

by:RodneyFirmer
Comment Utility
Thnaks for all your help. ended up finding software to do this.

cheers
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now