Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Chris Chris is offline
external usenet poster
 
Posts: 237
Default Changing more than one saved document at a time

Is it possible to insert headers & footers into ALL word documents already
created? Or atleast all word documents in any particular folder.

Also, is possible to change margins and font in more than one document at
once?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Changing more than one saved document at a time

Chris wrote:
Is it possible to insert headers & footers into ALL word documents
already created? Or atleast all word documents in any particular
folder.

Also, is possible to change margins and font in more than one
document at once?



In theory these are possible, but much depends on the nature of the
documents and what it is you want to change. If the documents have been
properly formatted using styles, changing the attached template would be a
simpler way to achieve the latter.

As for the former, do the documents (for example) have multiple sections?

For a simple document layout, the basic code would be something along the
lines of the following which opens each document in a selected folder. While
each document is open you can perform whatever changes you want on it - here
the filename is added to the document header, but you can add the code to
add stuff to the footer also and change the body of the document. Time to
investigate how vba works!

On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String

With Dialogs(wdDialogCopyFile)
If .Display 0 Then
DocDir = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
If Left(DocDir, 1) = Chr(34) Then
DocDir = Mid(DocDir, 2, Len(DocDir) - 2)
End If
DocList = Dir$(DocDir & "*.doc")
Do While DocList ""
Documents.Open DocList
'Open the document header (this will be the current page header here)
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

'Do what you want in the document header - here the document name is added
With Selection
.EndKey Unit:=wdStory
.Font.Name = "Arial"
.Font.Size = "8"
.ParagraphFormat.Alignment = wdAlignParagraphRight
.TypeText vbCr & ActiveDocument.FullName
End With

'Close the header or switch to the footer
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

'Save ad close the current document
ActiveDocument.Close SaveChanges:=wdSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
open doc at page where it was saved last time Steffen Meier Microsoft Word Help 2 April 3rd 07 04:25 PM
restoring a file to a previously saved time James Microsoft Word Help 4 November 15th 06 12:13 PM
Date and time info not being saved in document versions - Word 200 martin Microsoft Word Help 2 October 2nd 06 06:29 AM
Updating a word document saved in two locations at the same time? sch77 Microsoft Word Help 1 July 11th 05 10:42 AM
Changing time on all sheets Lindsey Microsoft Word Help 2 June 1st 05 03:40 AM


All times are GMT +1. The time now is 09:42 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"