OK, not a problem. I am neither a teacher nor an expert, but I will hang with you until you have it working. Like I say this piece of code is a work in progress. The snippet was cut directly from one of my workbooks. The other guy got it to work, but he sounds pretty experienced to me.
Excel is a dynamic environment. Unless you install a fresh copy (but don't do that) the actual keystroke sequence might vary. Please follow these steps and tell me where you have trouble.
1) Start Excel clean so you have
Book1
2) Type
Hello World in A1. You have to have something to print.
3) Press
alt-F11 you should see the
Visual Basic window, yes/no?
4) In the left upper corner should be a smaller window
Project - VBAProject if not press
ctrl-R yes/no?
5) This looks a little like a directory tree. The last item in the tree should be
ThisWorkbook Yes/no?
6) Double click
ThisWorkbook and a new window should appear to the right titled
Book1 - ThisWorkbook (Code) Yes/no?
7) Cut this code and paste it in the window.
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False
For Each wk In Worksheets
With ActiveSheet.PageSetup
.LeftHeader = "Last Modified on " & ActiveWorkbook.BuiltinDocumentProperties.Item("Last Save Time")
.CenterHeader = ""
.RightHeader = "Printed on &D &T"
.LeftFooter = "&F &A"
.CenterFooter = ""
.RightFooter = "Page &P of &N"
End With
Next
Application.ScreenUpdating = True
End Sub
Are we OK? yes/no
Save the workbook. You will get an error if you execute this code on a workbook that has not been saved.
9) Close the VBA Editor (press
alt-F11 again. Then
Print or
Preview Have we got it this time? Yes/no?
I truly hope this helps!
This message was edited by Rocky E on 2002-07-12 20:24