Excel Help

S

Scott

Not sure if I'm in the right area, but I have two questions to ask.

First, is there a way to use a "code" to distinguish between different parts
of the day with the Excel office 'Page Setup Header' funtion? What I'm
trying to do is have something say: if it is '4:30p.m.', then it is '2nd
shift'.

Second one, is there a way to have an input box to sign in before the user
opens a file? If so, is there also a way to save there 'login name' onto the
form that they print out or save as a file?

Thank you in advance.
Scott
 
G

Gord Dibben

I have assumed that first shift ends at 4:00PM and you are on a network with
users logging in.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim MyTime
MyTime = #4:00:00 PM#
With ActiveSheet
If Time > MyTime Then
.PageSetup.CenterFooter = Environ("username") & " second shift"
End If
End With
End Sub


Private Sub Workbook_BeforeSave(ByVal SaveAsUI _
As Boolean, Cancel As Boolean)
Dim MyTime
MyTime = #4:00:00 PM#
With ActiveSheet
If Time > MyTime Then
.PageSetup.CenterFooter = Environ("username") & " second shift"
End If
End With
End Sub

Copy/paste these......or whichever one you want......to Thisworkbook module.

Note: Environ("username") is the login name.

Second one.............in order for an inputbox to appear, the file must
already have been opened.

If you are looking to prevent unauthorized users from opening the workbook,
simply password to open the workbook.

If all you're looking for is a record of login name, the above will suffice.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top