Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
open doc at page where it was saved last time | Microsoft Word Help | |||
restoring a file to a previously saved time | Microsoft Word Help | |||
Date and time info not being saved in document versions - Word 200 | Microsoft Word Help | |||
Updating a word document saved in two locations at the same time? | Microsoft Word Help | |||
Changing time on all sheets | Microsoft Word Help |