none
With Excel Com, is there a way to change the File mode from Read-Only to Read-Write RRS feed

  • Question

  • Hey Guys,

    By design, opening an SharePoint excel file starts in 'Read-Only' Mode.  Is there a power shell command that can switch the mode to 'ReadWrite' without having to manually click the button.

    I've been tasked to update an excel file through PowerShell and the work around is saving the file, modifying it and then over-writing the existing file.

    I've tried the following:

    $Excel.Workbooks.Open($Source,0,$false)

    and

    $xlAccess = [Microsoft.Office.Interop.Excel.XlFileAccess]::xlReadWrite
    $sheet = $Excel.Workbooks.Open($Source)
    $sheet.ChangeFileAccess($xlAccess)
     which gives me an error

    Thanks

    Tuesday, March 6, 2018 6:39 PM

All replies

  • Hi savednotes,

    You had asked," Is there a power shell command that can switch the mode to 'ReadWrite' without having to manually click the button."

    Below is the command:

    gci -Include *.xls, *.xlsx -Recurse | % { if($_.IsReadOnly){$_.IsReadOnly= $false} }

    Reference:

    For a detailed step by step example ,You can refer link below.

    Use PowerShell to Find and Change Read-Only Files

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 7, 2018 6:51 AM
    Moderator
  • Hi,

    The file is from a internal SharePoint site ie: (\\intranet@SSL\..) and secondly, the file attribute is already set to False.  From what i read is that the behavior I'm experiencing is by designed.  I'm using the excel.application com object and wanted to know if there is maybe a setting that needs to be changed. 

    Thanks,

    P

    Wednesday, March 7, 2018 2:37 PM
  • Hi savednotes,

    You had asked,"wanted to know if there is maybe a setting that needs to be changed".

    There is no any settings are available that can change the Read Only file to Read Write while you open the file.

    You have to click the button to enable the editing for a file.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 8, 2018 1:37 AM
    Moderator