Solved

How to change 574 Word docs with 1 macro

Posted on 2004-03-31
6
447 Views
Last Modified: 2010-05-18
I have 574 word docs in 68 folders.

I constantly need to change the header in all docs with a new logo and address details. These are customized documents supplied to individual clients as a system; no two systems will ever be the same.

Is it possible to have each word doc look-up a global macro and use that macro to insert the new logo etc in its header?

That way if I need to make any changes to the macro (i.e. the drive and/or path to the document that contains the logo and address details), I’m only doing it in the one location. That’s going to be a lot easier than changing 574 word files 3 times week.
 
Thanks for the help - sorry 25 points is all I've got
0
Comment
Question by:bazoz
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 35 total points
ID: 10732141
Hi bazoz,

Here are a couple links that do something similar, let me know if you need more help

http://www.experts-exchange.com/Applications/MS_Office/Word/Q_20824362.html
http://www.experts-exchange.com/Applications/MS_Office/Word/Q_20814150.html

dragontooth

0
 
LVL 1

Author Comment

by:bazoz
ID: 10747596
Thanks Dragontooth,
That helped. This is the code I have and it works - but I would like it so that the inserted Linked file also gets automatically updated every time the document is opened.
Also, had a go at some code to deal with protected documents – but that didn’t work (see THIS DOES NOT below) – any ideas where I went wrong? Not all documents are protected.

---------- THIS WORKS ---------
Sub ChangeHeaderPath()
Application.ScreenUpdating = Ture
Set fs = Application.FileSearch
With fs
.LookIn = "G:\THEsystem\"
.SearchSubFolders = True
.FileName = "*.doc"
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Documents.Open fs.FoundFiles(i)
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.InsertFile FileName:="I:\THE System\Header.doc", Link:=True
ActiveDocument.Save
ActiveDocument.Close
Next i
Else
MsgBox "There were no files found"
End If
End With
End Sub

---------- THIS DOES NOT ---------
Sub ChangeHeaderPath()
Application.ScreenUpdating = False
Set fs = Application.FileSearch
With fs
.LookIn = "G:\THEsystem\"
.SearchSubFolders = True
.FileName = "*.doc"
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Documents.Open fs.FoundFiles(i)
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
ActiveDocument.Unprotect Password:=""
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.InsertFile FileName:="I:\THE System\Header.doc", Link:=True
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="" ' It errors on this line with 'The ToolsProtectDocument statement is currently disabled'
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.InsertFile FileName:="I:\THE System\Header.doc", Link:=True
End If
ActiveDocument.Save
ActiveDocument.Close
Next i
Else
MsgBox "There were no files found"
End If
End With
End Sub
0
 
LVL 1

Author Comment

by:bazoz
ID: 10749938
Have fixed the protected documents problem (missed out a line of code). Just the auto update now. And one new question – can you take the value from a text box and use that value as part of a macro?
i.e. I have a text box where I can enter the full path to the Header.doc this value can then be used in the macro above.
0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 10757586
On the textbox Yes, it would be accessed like textbox1.text to get the text from the textbox. Not knowing how your macro is written my best guess at how to do this is - have a global variable with a default destination, this way if no one fills in the textbox the process will continue. Assign the global variable with the value in the textbox on the onexit event may need to include some type of validation there also eg verify that the drive and directory exists I would also recommed thet you use the fully qualified path name, if some of the users do not map their drives to "I" your code will break.

Looking into the links update.

dragontooth

0
 
LVL 1

Author Comment

by:bazoz
ID: 11521208
Moving the whole project over to InfoPath, too many hurdles to overcome using Word.
But dragontooth can have the points as I did get part of it to work.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

707 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

15 Experts available now in Live!

Get 1:1 Help Now