PDA

View Full Version : Sleeper: Print Log



austenr
06-08-2005, 10:52 AM
Hi everyone. I am trying to make a print log. Does anyone see what is wrong with this Sub:


Public Sub Workbook_BeforePrint(Cancel As Boolean)
Dim LastRow As Long
Dim PrintLog As Worksheet
Set PrintLog = Worksheets("Sheet2")
LastRow = PrintLog.Range("A65536").End(xlUp).Row + 1
With PrintLog
.Cells(LastRow, 1).Value = Now()
.Cells(LastRow, 2).Value = Application.UserName
.Cells(LastRow, 3).Value = ActiveSheet.Name
End With
End Sub

mdmackillop
06-08-2005, 11:06 AM
Hi Austin,

It works for me. Are you having a problem?
The issues I see are:
If I go to the dialog via File/Print it enters the item before I click the print button, hence cancelled operations will be listed
If I select multiple sheets, only the first is recorded.

austenr
06-08-2005, 11:33 AM
Yea...I am trying to run it but if I put the cursor in the VBE and press F5 nothing happens. Also if you go the long way around through Tools>Macro>Macros, nothing shows up in the list as a macro. ??? On a related note I am having problems with something else. Thought I would put it in here instead of starting anew thread.

I have the following routine for printing but it does not work in 97. I created it in 2003. I know it has something to do with the sort statement. Can you take a look?


Selection.Sort Key1:=Range("C3"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'DataOption1:=xlSortNormal

Have a feeling that it is the DataOption1 statement..Is there some of this I can eliminate?

gsouza
06-08-2005, 12:38 PM
Put the code in the workbook part of VBE then when you hit the print icon the program will run.

Killian
06-08-2005, 12:48 PM
Indeed the code will need to be in the Workbook code sheet rather than a standard module.
And the subs declared as Private don't show in the Run Macro list

Norie
06-08-2005, 01:07 PM
austenr

Code that requires parameters such as the BeforePrint event will not run when you press F5.

geekgirlau
06-08-2005, 06:57 PM
I have the following routine for printing but it does not work in 97. I created it in 2003. I know it has something to do with the sort statement. Can you take a look?


Austenr, I would think that since your sort is standard, you could reduce it to the following:



Selection.Sort Key1:=Range("C3"), Order1:=xlAscending, Header:=xlGuess


I don't have 97 to test this, but give it a try