macro command

  • Thread starter Thread starter Dawn
  • Start date Start date
D

Dawn

I need to have a macro print a file, but only after the
workbook has been activated 5 times.

Thanks!
Dawn
 
I need to have a macro print a file, but only after the
workbook has been activated 5 times.

1. By file, do you mean all sheets?
2. By activated, do you mean opened?

You could use code in the This Workbook module, eg:

Private Sub Workbook_Open()
Range("Sheet1!A1") = Range("Sheet1!A1") + 1
If Range("Sheet1!A1") = 5 Then
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
Range("Sheet1!A1") = 0
End If
ActiveWorkbook.Save
End Sub

To access the module, right-click the icon left of File in the menu bar,
choose View Code. But ...

3. Anyone could skip this by disabling macros on opening the file. So
possibly the only way if you *have* to have it is to password-protect the
file, then users would *have* to ask you to open it & you'd know which Nth
opening it was.

Rgds,
Andy
 
Opening the file. In the macro currently I have it opening
the file entering information and closing. I want a print
out after the 5th entry if possible.?? Does this help any?
 
Opening the file. In the macro currently I have it opening
the file entering information and closing. I want a print
out after the 5th entry if possible.?? Does this help any?

Not especially. What kind of info? What constitutes "an entry" - a single
cell? Or perhaps 1 entry = all details of a sale (such as Customer --
Date -- Item -- Qty -- Price etc.). Throw us a bone here.

Rgds,
Andy
 
Back
Top