Machine Recognition

jeffalex2

New Member
Joined
Apr 22, 2011
Messages
4
Is there vba code for the workbook to recognize the user and what machine it's on when you open it? I've created a spreadsheet that has proprietary company info in it and I'd like to write a string that erases data if the workbook is opened on an unauthorized machine.

BTW...this is my 1st post but this site has been indispensable in the development of my project...

Thanks!!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You might be able to do something with "SaveSetting" & "GetSetting" (see VBA help) which allows you to read & write data to the registry. Because the data is in the registry it is specific to a certain machine and that data could indicate the user ID. On workbook open, No registry entry = problem or check ID if registry entry exists.

You could use a password protected macro to initialize the registry entry(s).

Hope that helps.

Gary
 
Upvote 0
Hi jeffalex2,

Welcome to the MrExcel forum!!

The Environ (VBA only) function should do the job:

Code:
MsgBox Environ("UserName") 'Windows user name
    MsgBox Environ("ComputerName") 'Machine name

HTH

Robert
 
Upvote 0

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

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