Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
BATCH insert header & footer
Hi,
I have several ".doc" files (Word 2000) that I need to print off, with the filename and path (path too, ideally, but just filename will suffice if it has to). I am aware of how to open a single file and add in a header with the path and file name, but I want to do this to several hundred files as quickly as possible. Can you help please? Regards, Neil |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
BATCH insert header & footer
The following macro will print all the documents in a chosen folder with the
filename and path added in the header, right aligned in 8 point Arial The changes are not saved to the documents - Test with a small sample to ensure it does what you want. Sub PrintWithFileNames() 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 Selection.EndKey Unit:=wdStory ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader With Selection .EndKey Unit:=wdStory .Font.Name = "Arial" .Font.Size = "8" .ParagraphFormat.Alignment = wdAlignParagraphRight .TypeText vbCr & ActiveDocument.FullName End With ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument ActiveDocument.PrintOut ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges DocList = Dir$() FirstLoop = False Loop Application.ScreenUpdating = True Exit Sub err_FolderContents: MsgBox Err.Description Exit Sub End Sub See http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org neilmonk wrote: Hi, I have several ".doc" files (Word 2000) that I need to print off, with the filename and path (path too, ideally, but just filename will suffice if it has to). I am aware of how to open a single file and add in a header with the path and file name, but I want to do this to several hundred files as quickly as possible. Can you help please? Regards, Neil |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
BATCH insert header & footer
Perfect!
You Graham, are a star! Thanks so much, this has really saved me hours and hours! All the best, Neil. "Graham Mayor" wrote: The following macro will print all the documents in a chosen folder with the filename and path added in the header, right aligned in 8 point Arial The changes are not saved to the documents - Test with a small sample to ensure it does what you want. Sub PrintWithFileNames() 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 Selection.EndKey Unit:=wdStory ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader With Selection .EndKey Unit:=wdStory .Font.Name = "Arial" .Font.Size = "8" .ParagraphFormat.Alignment = wdAlignParagraphRight .TypeText vbCr & ActiveDocument.FullName End With ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument ActiveDocument.PrintOut ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges DocList = Dir$() FirstLoop = False Loop Application.ScreenUpdating = True Exit Sub err_FolderContents: MsgBox Err.Description Exit Sub End Sub See http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org neilmonk wrote: Hi, I have several ".doc" files (Word 2000) that I need to print off, with the filename and path (path too, ideally, but just filename will suffice if it has to). I am aware of how to open a single file and add in a header with the path and file name, but I want to do this to several hundred files as quickly as possible. Can you help please? Regards, Neil |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
BATCH insert header & footer
You are welcome
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org neilmonk wrote: Perfect! You Graham, are a star! Thanks so much, this has really saved me hours and hours! All the best, Neil. "Graham Mayor" wrote: The following macro will print all the documents in a chosen folder with the filename and path added in the header, right aligned in 8 point Arial The changes are not saved to the documents - Test with a small sample to ensure it does what you want. Sub PrintWithFileNames() 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 Selection.EndKey Unit:=wdStory ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader With Selection .EndKey Unit:=wdStory .Font.Name = "Arial" .Font.Size = "8" .ParagraphFormat.Alignment = wdAlignParagraphRight .TypeText vbCr & ActiveDocument.FullName End With ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument ActiveDocument.PrintOut ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges DocList = Dir$() FirstLoop = False Loop Application.ScreenUpdating = True Exit Sub err_FolderContents: MsgBox Err.Description Exit Sub End Sub See http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org neilmonk wrote: Hi, I have several ".doc" files (Word 2000) that I need to print off, with the filename and path (path too, ideally, but just filename will suffice if it has to). I am aware of how to open a single file and add in a header with the path and file name, but I want to do this to several hundred files as quickly as possible. Can you help please? Regards, Neil |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
adding headers and footers to a word document | Microsoft Word Help | |||
Header and Footer area have vanished (Word 2002) | Microsoft Word Help | |||
Pasting into a Header and Footer document issue | Microsoft Word Help | |||
Preventing deletion of header | Microsoft Word Help | |||
Same header but even/odd footer (sorry for the new thread) | Page Layout |