Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Filepath

Status
Not open for further replies.

deesheeha

Programmer
Jul 28, 2006
38
IE
Hi,

I have code thats reading in from a file on my local drive. there are 1000 html pages there and what its doing is its reading them in one by one and then printing them out. I want to add the filepath to the end of each page that it prints so i know what file they are talking about.

can anyone help me with this???? below is the code:

Sub PrintFiles()
'will print all excel files in C:\Data
'By: Ron de Bruin
Dim i As Long
Dim WB As Document

With Application.FileSearch
.NewSearch
.LookIn = "F:\Documents and Settings\Peter\Desktop\Bua Discovery Files" '****Change path here*****
.SearchSubFolders = True
.FileType = msoFileTypeWebPages
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Set WB = Documents.Open(.FoundFiles(i))
WB.PrintOut Copies:=1
WB.Close False
Next i
End If
End With

End Sub

Thanks for your help
Dee
 
A starting point:
For i = 1 To .FoundFiles.Count
Set WB = Documents.Open(.FoundFiles(i))
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.EndKey Unit:=wdStory
Selection.TypeText Text:=.FoundFiles(i)
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
WB.PrintOut Copies:=1
WB.Close False
Next i


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
1. Why bother making a document object? You are using ActiveDocument anyway.

2. Don't use ActiveView as it is actually using the user interface. It opens the HeaderFooter View, moves the Selection to the end, types in text, and changes View back out of header View. You can simply put the text directly into the footer. In the code below, it puts it at the end of any existing content. This could be altered. Maybe a line break, maybe just some space. You could also use it to replace the footer content - whatever you want.

Code:
For i = 1 To .FoundFiles.Count
  Documents.Open(.FoundFiles(i))
  With ActiveDocument
    .Sections(1).Footers(1).Range. _
        InsertAfter Text:= .FoundFiles(i)
    .PrintOut Copies:=1
    .Close False
  End With
Next i

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top