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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,804
Messages
6,121,652
Members
449,045
Latest member
Marcus05

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
Back
Top