Consulting

Results 1 to 4 of 4

Thread: Worksheet ReadOnly?

  1. #1

    Worksheet ReadOnly?

    Hi

    Basically I want a worksheet to become read only, is there any way of implementing this?

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    To make a worksheet read only you would need to make sure cells are locked and then apply worksheet protection, however to make a workbook read only you could use this:
    [VBA]
    Private Sub Workbook_Open()
    ThisWorkbook.ChangeFileAccess xlReadOnly
    End Sub
    [/VBA]then everytime your workbook is opened it will be read only!

    Regards,
    SImon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Quote Originally Posted by bopo
    Hi

    Basically I want a worksheet to become read only, is there any way of implementing this?
    worksheet -> WorkBook.
    [VBA]Set WB = Workbooks.Open("C:\FolderName\WorkBookName.xls", False, True)[/VBA]
    M.Aytaş

  4. #4
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    For worksheets:
    [vba]Worksheets("Sheet1").Protect Password:="MyPassword", userinterfaceonly:=True[/vba]

    Change the sheet name (or put it in a loop), and change the password or elminate it all together. The UserInterfaceOnly argument sets it to allow macros to run on the worksheet, but prevent users from editing "locked" fields.

    Be warned that the UserInterfaceOnly setting does not persist when Excel is closed. If you want that feature, I'd suggest a routine called from your Workbook_Open routine that re-protects the applicable sheets.

    HTH,
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •