hi i really need help!!

  • Thread starter Thread starter kris
  • Start date Start date
K

kris

hi , right now im currently trying to add the filename and path to the top of
a document, which is no problem. THe problem is that I have to do the same to
1000 different documents. Is there a faster way instead of opening up each
document manually to do that?
 
If you want to add same filename and path on each page, then you can use
header

option available on insert tab. Once you enter the header will make
information

available on every page.
 
Sorry, my answer is not correct.

I misunderstood the question.

Thank you.
 
It is possible to do this using a batch processing macro. The bigger problem
would occur if the documents were randomly created using a variety of
templates and there was content already in the document header and if there
was more than one header in the document, in which case where would you want
to put the filename in relation to any headers already present? The
following macro contains the basic code. It takes no account of existing
headers nor will work with protected documents. It simply puts the filename
at the end of the first page header. *Use on copies of the documents*.

Sub BatchFileNamesinHeader()
On Error GoTo err_FolderContents
Dim myFile As String
Dim DocList As String
Dim DocDir As String
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select Folder containing the documents to be modifed and click
OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
PathToUse = fDialog.SelectedItems.Item(1)
If Right(PathToUse, 1) <> "\" Then PathToUse = PathToUse + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
myFile = Dir$(PathToUse & "*.do?")

While myFile <> ""
Set myDoc = Documents.Open(PathToUse & myFile)
Selection.HomeKey Unit:=wdStory
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection
.EndKey Unit:=wdStory
.Font.name = "Arial"
.Font.Size = "8"
.ParagraphFormat.Alignment = wdAlignParagraphRight
.TypeText ActiveDocument.FullName
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
myDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
Application.ScreenUpdating = True
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
End Sub

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top