Workbook by default open in Read-Only mode with Commandbutton to normal mode

  • Hello,


    Because several users have to read an excelfile(that is placed on a shared folder), it would be interessant to, by default open the workbook in the Read-Only Mode, and by clicking a commandbutton, place the file in normal mode.
    In that way, while the file is read by different users, another user still can change the file.
    Now it is mostly the case, once the file is opened, an other user can not change the file, and yet, the file is opened by users who are only consulting.


    So, is it possible to always let the workbook open in Read-Only mode, and with a commandbutton put the workbook in Normal mode?


    Thanks in advance,


    aisietie

  • Re: Workbook by default open in Read-Only mode with Commandbutton to normal mode


    Hello,


    Can I understand here, that what I want is impossible?


    Grtz


    aisietie

  • Re: Workbook by default open in Read-Only mode with Commandbutton to normal mode


    What you are looking for is


    ChangeFileAccess property of the workbook class


    To Thisworkbook module to open as ReadOnly

    Code
    Private Sub Workbook_Open()
        Me.ChangeFileAccess 3  '<- read only
    End Sub


    And code for the command button looks like

    Code
    With ThisWorkbook
        If .ReadOnly Then
            .ChangeFileAccess 2  '<- read-write
        Else
            .ChangeFileAccess 3  '<- read only
        End If
    End With
  • Re: Workbook by default open in Read-Only mode with Commandbutton to normal mode


    Jindon,


    That is a great help.
    I will try this in my project.
    Thanks,


    aisietie

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!