Remove attributes from Word .doc files in a batch

Posted on 2010-09-22
Last Modified: 2012-05-10

is there a way to remove attributes from a batch of word/excel docs ? I have documents and spreadsheets that have be moved on a server that are trying to reference and old workstation for the template every time you open them which is causing delays in opening.

If I open the document in word/excel 2010 and use the document inspector it finds the attributes which are document properties and personal information. When I remove these attributes the problem is resolved. The issue I have is that I have thousands of documents.

Any Ideas?
Question by:gilliganwedge2
  • 2
LVL 11

Expert Comment

ID: 33732707

There is a shareware tool that allows batch processing of properties on word files that worked pretty well for me -

Perhaps you will find this useful, too.

Expert Comment

ID: 33732724
This requires a script of some kind.  THe basic construct is this:

1. unzip the *.docx file
2. Either load contents into an xml object of some kind (depends on language) or search and replace text
3. zip again

docx and xlsx files are really just zipped xml files.  Once you unzip them you can work with just like xml.  There may be a tool for this online, but I don't know of one personally.  
LVL 76

Accepted Solution

GrahamSkan earned 500 total points
ID: 33733549
This question has been asked a number of times in this forum.
The macro below is taken from this one:

It does a recursive search for all documents in a folder and its subfolders.

It needs to be called thus:

FindFiles "C:\MYFolder", *.doc*
Sub FindFiles(strFolder As String, strFilePattern As String)

    Dim strFileName As String

    Dim strFolders() As String

    Dim iFolderCount As Integer

    Dim i As Integer

    Dim wdDoc As Word.Document


    'collect child folders

    strFileName = Dir$(strFolder & "\", vbDirectory)

    Do Until strFileName = ""

        If (GetAttr(strFolder & "\" & strFileName) And vbDirectory) = vbDirectory Then

            If Left$(strFileName, 1) <> "." Then

                ReDim Preserve strFolders(iFolderCount)

                strFolders(iFolderCount) = strFolder & "\" & strFileName

                iFolderCount = iFolderCount + 1

            End If

        End If

        strFileName = Dir$()



    'process files in current folder

    strFileName = Dir$(strFolder & "\" & strFilePattern)

    Do Until strFileName = ""


            Set wdDoc = Documents.Open(strFolder & "\" & strFileName)

            If wdDoc.AttachedTemplate.Path = "\\Oldserver\templates\" Then

                wdDoc.AttachedTemplate = "\\NewServer\templates\" & wdDoc.AttachedTemplate.Name

                wdDoc.Close wdSaveChanges


                wdDoc.Close wdDoNotSaveChanges

            End If

        strFileName = Dir$()



    'look through child folders

    For i = 0 To iFolderCount - 1

        FindFiles strFolders(i), strFilePattern

    Next i

End Sub

Open in new window

LVL 76

Expert Comment

ID: 33733561
Oops. missed the quotes around *.doc*.

It should be:

FindFiles "C:\MYFolder", "*.doc*"

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

863 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

21 Experts available now in Live!

Get 1:1 Help Now