Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



How to make Excel VBA Read Only

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 09-05-2009
Member
 
Join Date: Jan 2009
Posts: 74
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.
Reply With Quote
  #2  
Old 09-05-2009
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,502
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.
Reply With Quote
  #3  
Old 09-05-2009
Aarpitt's Avatar
Member
 
Join Date: Dec 2008
Posts: 165
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
Reply With Quote
  #4  
Old 09-05-2009
Member
 
Join Date: Jan 2009
Posts: 74
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.
Reply With Quote
  #5  
Old 09-05-2009
amit shah's Avatar
Member
 
Join Date: Dec 2008
Posts: 102
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
Reply With Quote
  #6  
Old 12-05-2009
Member
 
Join Date: May 2009
Posts: 1
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!
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 05:17 AM.