Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
neilmonk neilmonk is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
neilmonk neilmonk is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding headers and footers to a word document PhilB Microsoft Word Help 12 October 10th 06 07:13 PM
Header and Footer area have vanished (Word 2002) Mark Microsoft Word Help 5 May 10th 06 04:33 PM
Pasting into a Header and Footer document issue Christian Blackburn Microsoft Word Help 1 April 20th 06 09:56 PM
Preventing deletion of header Jag Man Microsoft Word Help 10 August 11th 05 09:14 PM
Same header but even/odd footer (sorry for the new thread) B?atrice Karjalainen Page Layout 1 December 16th 04 12:40 AM


All times are GMT +1. The time now is 12:56 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"