# -*- coding: iso-8859-1 -*- #. // _ex_Open.py #. // Ouvrir un classeur. def ex_Open( oExcel, FileName, aOptions = [] ): UpdateLinks = 1 ReadOnly = False # // Défaut. Format = None Password = None WriteResPassword = None IgnoreReadOnlyRecommended = None Origin = True Delimiter = None Editable = None Notify = False Converter = False AddToMru = None Local = False # // Défaut. CorruptLoad = 0 if len( aOptions ) > 0: for i in range( 0, len( aOptions ), 2 ): if aOptions[ i ] == "UpdateLinks": UpdateLinks = aOptions[ i + 1 ] elif aOptions[ i ] == "ReadOnly": ReadOnly = aOptions[ i + 1 ] elif aOptions[ i ] == "Format": Format = aOptions[ i + 1 ] elif aOptions[ i ] == "Password": Password = aOptions[ i + 1 ] elif aOptions[ i ] == "WriteResPassword": WriteResPassword = aOptions[ i + 1 ] elif aOptions[ i ] == "IgnoreReadOnlyRecommended": IgnoreReadOnlyRecommended = aOptions[ i + 1 ] elif aOptions[ i ] == "Origin": Origin = aOptions[ i + 1 ] elif aOptions[ i ] == "Delimiter": Delimiter = aOptions[ i + 1 ] elif aOptions[ i ] == "Editable": Editable = aOptions[ i + 1 ] elif aOptions[ i ] == "Notify": Notify = aOptions[ i + 1 ] elif aOptions[ i ] == "Converter": Converter = aOptions[ i + 1 ] elif aOptions[ i ] == "AddToMru": AddToMru = aOptions[ i + 1 ] elif aOptions[ i ] == "Local": Local = aOptions[ i + 1 ] elif aOptions[ i ] == "CorruptLoad": CorruptLoad = aOptions[ i + 1 ] #. endif #. endfor i #. endif oBook = oExcel.Workbooks.Open( FileName , UpdateLinks , ReadOnly , Format , Password , WriteResPassword , IgnoreReadOnlyRecommended , Origin , Delimiter , Editable , Notify , Converter , AddToMru , Local , CorruptLoad ) return oBook ''' Dernière modification : 2022-02-12 [Exemple] import sys sys.path.append( "modules" ) from _ex_Open import ex_Open # // Ouvrir un classeur. from _ex_ExcelNew import ex_ExcelNew # // Ouvre Excel. from _ex_GetFile import ex_GetFile # // Ouvrir un fichier avec une boîte de dialogue en Excel. oExcel = ex_ExcelNew() xlsxIn = ex_GetFile( oExcel ) if xlsxIn: oBook = ex_Open( oExcel, xlsxIn, [ "ReadOnly", True ] ) oSheet = oBook.Worksheets( 1 ) oExcel = None [/Exemple] https://docs.microsoft.com/en-us/office/vba/api/Excel.Workbooks.Open FileName // Nom du fichier avec son chemin : obligatoire dans mes scripts. UpdateLinks // ReadOnly // True si en lecture seule. Format // Format pour fichiers texte. Password // WriteResPassword // IgnoreReadOnlyRecommended // Origin // Delimiter // Editable // Notify // Converter // AddToMru // Local // True enregistre les fichiers dans la langue de Microsoft Excel // (y compris les paramètres du panneau de configuration). // False (valeur par défaut) enregistre les fichiers dans la // langue de Visual Basic pour Applications (VBA) // (qui est généralement l'anglais des États-Unis, // sauf si le projet VBA à partir duquel Workbooks.Open est exécuté // est un ancien projet VBA XL5/95 internationalisé). CorruptLoad // '''