?
Solved

How to change 574 Word docs with 1 macro

Posted on 2004-03-31
6
Medium Priority
?
454 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
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 …
Suggested Courses

752 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