?
Solved

How to change 574 Word docs with 1 macro

Posted on 2004-03-31
6
Medium Priority
?
455 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 105 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
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 video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Suggested Courses

650 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