|
| |||||||||
| Tags: excel, read only, vba |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to make Excel VBA Read Only
Hi friends, I have created a workbook in excel and i don't want anyone to make any changes in it, they should only be able to ready those Excel file and cannot write in that file.In short i need to have my Excel VBA in read only format.Can anyone help me out with this issue. |
|
#2
| ||||
| ||||
| Re: How to make Excel VBA Read Only
The ReadOnly property will not allow you to set the property it's only being used to check whether workbook is ReadOnly or not.For making your workbook Readyonly with all users you need to use SaveAs Method. |
|
#3
| ||||
| ||||
| Re: How to make Excel VBA Read Only
Try to use the code for making you Excel workbook ReadOnly Code: Sub Workbook_Open
If Environ("Username") = "Administrator" or Environ("Username") = "XYZ" then
Workbooks.Open "c:\demo.xls"
Else
Workbooks.Open "c:\demo.xls", , True
End If
End Sub |
|
#4
| |||
| |||
| Re: How to make Excel VBA Read Only
I have tried to use the above code for Excel but it's says me do you want to reopen the Excel file which should not happen i should be able to open workbook as ReadOnly at first time only. |
|
#5
| ||||
| ||||
| Re: How to make Excel VBA Read Only
Try to use the below code for making you Excel file in ReadOnly mode. Code: Private Sub Workbook_Open()
Application.DisplayAlerts = False
If Environ("Username") = "Administrator" or Environ("Username") = "XYZ" then
MsgBox "It's in Edit mode"
Workbooks.Open "d:\Example.xls"
Else
MsgBox "It's in Read Only mode"
Workbooks.Open "d:\Example.xls", , True
End If
Application.DisplayAlerts = True
End Sub |
|
#6
| |||
| |||
| Re: How to make Excel VBA Read Only
Hi Amit, How would I modify the code if I want all users to open the workbook in read-only but have a macro that will run automatically everytime the workbook is opened? This macro will need to update some fields, so the workbook should be in write mode, right? But the user has it opened it read-only? Please share suggest possible solutions, thanks! |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to make Excel VBA Read Only" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to read Text File in Excel via VBA | Rish!On | MS Office Support | 7 | 1 Week Ago 04:51 PM |
| How to make iTunes read my disc instead of grace note | Shantiprakash | Portable Devices | 3 | 23-02-2011 10:55 AM |
| How to read Excel (xls file) From C# | KornFlexia | MS Office Support | 3 | 16-12-2010 08:24 AM |
| Word & Excel files all Read Only | rich | MS Office Support | 4 | 22-10-2010 10:51 AM |
| Read information from Excel to VB | Jateen | Software Development | 2 | 06-01-2009 03:28 PM |