help: Restrict access to Excel files

thunder_anger

Board Regular
Joined
Sep 27, 2009
Messages
206
Dear all

after i worked hard on my file
i want the file to open just in one computer and if copied to another computer it won't work

is that Possible?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
thunder_anger,

What version of Excel are you using?

Are you familiar with the VBA Editor?
 
Upvote 0
thunder_anger,


Open a new workbook.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Sub Test()
ActiveSheet.Range("A1") = Environ("USERNAME")
End Sub


Then run the Test macro.


Copy the contents of cell A1, and let ke know what the Environ("USERNAME") is.
 
Upvote 0
the PC belongs to HR department and the thing that i want to do is to open the file on this PC and if copied to any other computer it will not work
Note: All PCs Office packages are Macro Enabled
 
Upvote 0
thunder_anger,

With the test workbook, replace the last macro code with the following.


Code:
Sub Test()
ActiveSheet.Range("A1") = Environ("USERPROFILE")
End Sub


Run the Test macro again.

What does cell A1 contain?
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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