Excel

Bonjour,
Comment verifier si lors de l’ouverture d’un fichier excel, celui-ci est en lecture seule ou non…?

D’avance merci.

If the Excel file has the [Read-Only] property set, then the string “[Read-Only]” will appear in Excel’s Caption.

[code]Dim f as New folderitem
f=GetOpenFolderItem(“text/plain”)

Dim excel as new ExcelApplication
excel.Visible = True

excel.Workbooks.Open(f.NativePath)

//[Read-Only] will appear in Excel Caption
If InStr(excel.Application.Caption, “[Read-Only]”) <> 0 then
MsgBox “This file is read-only”
Else
MsgBox “This file not read-only”
End If

//Close excel
excel.ActiveWorkbook.close false
excel.Quit
excel = nil

Exception err as OLEException
MsgBox err.message[/code]

Si le fichier Excel a la propriété [Lecture seule] fixée, alors la chaîne de caractères Lecture seule ("[Read Only]") sera affichée dans la légende (Caption) d’Excel.

Traduction libre; je n’ai pas utilisé Excel depuis près de 20 ans…

@Emile Schwarz , Thank you for the translation. My french is horrible. :slight_smile:

I was thinking “Julien does not know english if he ask in the French channel", so a little help can be welcome.

Better have an horrible French than no French at all…

(I went to Germany to repair the brakes of my car and I was uneble to ask what I wanted in German. I used Translate Google and wrote some sentences in German before going to the mechanical shop).

Thanks !!
J’arrive a comprendre l’anglais en lisant… Mieux qu’en ecrivant…!
Sinon, je peux toujours utiliser google translate!!:slight_smile:

Merci a vous !!!

@Eugene Dakin
When excel starts, it goes in the background. Never in the foreground.
And when the file is read-only, the code of xojo waits for me to click on the msgbox of excel (which already informs me that I am read-only, to continue executing and to re-inform me that I am in Read only … how to avoid this?

[quote=335826:@jean-paul devulder]if not f.iswriteable then

// ce fichier est en mode read only

end if[/quote]
Ne marche pas du tout, pour le coup.

[quote=335824:@julien assayah]@Eugene Dakin
When excel starts, it goes in the background. Never in the foreground.[/quote]

The answer is at this link: Apportez Excel a l’avant

[google translate]
Créez une nouvelle conversation avec une nouvelle question :slight_smile:
Please create a new conversation with a new question :slight_smile:

excel.Application.DisplayAlerts = False

PS: please pardon typing errors as this was typed on a phone