View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How can I automatically print file path on documents

Just another option (that I wouldn't use)...

You can create a new workbook and put this in the ThisWorkbook module.

Option Explicit
Public WithEvents xlApp As Excel.Application
Private Sub Workbook_Open()
Set xlApp = Application
End Sub
Private Sub Workbook_Close()
Set xlApp = Nothing
End Sub
Private Sub xlApp_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
Dim sht As Object
For Each sht In Wb.Sheets
sht.PageSetup.CenterFooter = Wb.FullName
Next sht
End Sub


Save this workbook in your XLStart folder. Each time excel starts, this
workbook will open and the workbook_open event will fire. It'll create an
application event that fires each time you print (or print preview) that changes
the center footer to the workbook's full name (including drive, path and
filename).

The reason I wouldn't use this is that you don't get an option to not have this
happen. It'll affect all your workbooks--even the ones that shouldn't have
their footers changed.

I'd either use the stuff built into excel (using Gord's suggestion for new
workbooks) or the addin from John Walkenbach.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

You can read a lot more about application events at Chip Pearson's site:
http://www.cpearson.com/excel/AppEvent.htm

Brenda @ FCA wrote:

Thank you, but I think what you're describing would have to be set up on each
document each time--I was looking to have it happen automatically whenever a
document was saved.

Brenda

"Dave Peterson" wrote:

If you're using xl2002+, you can include the path in the header/footer via
file|Page setup|header/footer tab.

If you're using xl2k and below, you may want to get John Walkenbach's AddPath
addin:
http://j-walk.com/ss/excel/files/addpath.htm

Brenda @ FCA wrote:

We would like to set up our employees Office docs to automatically add and
print the file path, including file name, as a footer on all Excel and Word
documents.
We think we had this set up at one time, but lost it in an upgrade and now
can't seem to find how to do it.

Thanks.


--

Dave Peterson


--

Dave Peterson