0

This is my 1st post here :)

I am writing a powershell code that triggers a macro in an Excel workbook.

The code works just fine, but I have an issue that the code openes the file as a Read Only. The problem does not occur, when I open the file manually.

When I tried to get isReadOnly value, Powershell advised me that the specific file does not have such a value. I tried also Trust Center and Antivirus solutions as per Microsoft website (https://learn.microsoft.com/en-us/sharepoint/troubleshoot/lists-and-libraries/files-open-as-read-only-and-cannot-check-in-or-out).

I tried also solution from here: How to get PowerShell to supress read-only mode, and allow editing when opening Excel workbook? , without any effect

$excel = New-Object -comobject Excel.Application  
 
$FilePath = 'SharePoint/testTest.xlsm'
$workbook = $excel.Workbooks.Open($FilePath)
$excel.Visible = $true  

$app = $excel.Application
$app.Run("Macro1") 
$excel.Quit() 

Can I somehow force opening it as editable?

Bart
  • 36
  • 5
  • Does your `$FilePath` contain `...sharepoint.com/:x:/r/`? – CLR Jun 28 '23 at 12:53
  • Yes - I checked the path, it works fine, as the file itself opens. – Bart Jun 28 '23 at 12:55
  • 3
    If so, change `..sharepoint.com/:x:/r/foldername` to `..sharepoint.com/foldername` - as the /r/ tells it to open read-only. – CLR Jun 28 '23 at 12:56

0 Answers0