Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Forcing read-only

  1. #1
    Board Regular EconSean's Avatar
    Join Date
    Apr 2002
    Location
    Philadelphia, PA
    Posts
    129
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I was wondering if someone could instruct me on how to force Excel to open a file as read-only.

    I tried this in the Auto_Open sub, but the user is still prompted (I don't want them to be able to click "No" when asked if they should open as read only, I want the "Yes" forced on them.):

    Application.DisplayAlerts = False

    I hope this makes sense. Thanks in advance for any hints.

    Regards,

    Sean

  2. #2
    Board Regular wilkisa's Avatar
    Join Date
    Apr 2002
    Location
    Decatur IL, USA
    Posts
    635
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The only way I know to set it as read-only so that you are NOT prompted to say Yes or NO, is to go into the Windows Explorer, locate the file, right-click and go to Properties and change the file properties to READ-ONLY.

    I hope this helps
    Thanks,
    Shirlene

  3. #3
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Depends on what you're doing. If it's for your sake, you need to open the file with a VBA procedure (from a different workbook) with your alerts turned to false.

    If it's to make decisions for others, you'll need to save the file with Windows variety of read-only (like wilkisa mentioned) with code like:

    Code:
    SetAttr activeworkbook.fullname, vbReadOnly
    Hope this helps.



    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-05-10 09:20 ]

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Or you could try:-

    Private Sub Workbook_Open()
    ThisWorkbook.ChangeFileAccess xlReadOnly
    End Sub

    Obviously you could allow certain people read/write access by use of some IF statements and by checking some criteria e.g. the Windows username.

    HTH,
    Dan

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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