Forcing users to log on to use a worksheet

sbachrach

New Member
Joined
Nov 3, 2002
Messages
1
I want to be able to force users to log in, using a form, before being allowed to use a workbook.

Is there an easy macro that I can write to do this? Can I record the user on the worksheet?

Any help gratefully recieved.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
If you are on Windows NT you can use the NT login as a security check

eg

Sub AUTO_OPEN

USER = Environ("Username")

If USER <> .... THEN
MSGBOX "You Do Not Have Access Rights to This File",vbcritical,"NO ACCESS"
ActiveWorkbook.Close SaveChanges = True
END IF


Environ("Username") is very handy for running auto open macros as you can predetermine external queries and reports etc on the user basis (i.e. by dept) without requiring any interaction by the user. Unless they know how to log on as someone else it's also pretty safe.
 

Richie(UK)

MrExcel MVP
Joined
May 17, 2002
Messages
3,329
Hi sbachrach

Welcome to the board. :)

In order to do what you are proposing you will need to force the users to enable macros, otherwise the login form will not be displayed.

This basically involves using the Before_Close event to hide (xlVeryHidden) all sheets except one on closing, that one sheet should contain a message advising users that they must enable macros to use the workbook. Then in the Open event you unhide the sheets again.

In your case, you would also make the user complete the login before unhiding the sheets.

(I'm pretty sure the issue of forcing macro use has been covered before. If you need some pointers do a search on that topic. Any problems repost on this thread).

HTH
 

Forum statistics

Threads
1,144,312
Messages
5,723,651
Members
422,508
Latest member
Lordkit1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top