Page 1 sur 1

[R] fermer un fichier excel

Posté : mar. 22 juil. 2014 17:00
par emanemos
Bonjour,

je n'arrive pas à enregister & fermer le fichier !!!!! je bloque après le msgbox ....

Une idée ???

Code : Tout sélectionner

$oExeResult = _SQLQuery($Db_oConn, "SELECT * FROM Exclus;" )

Local $oAppl = _Excel_Open (True,False,True,True,True)
$oWorkbook = _Excel_BookNew($oAppl, 1)
$oAppl.ActiveWorkBook.ActiveSheet.Cells(1,1).CopyFromRecordset ($oExeResult)
local $RowCount = $oWorkbook.ActiveSheet.UsedRange.Rows.Count
Msgbox(1,"Liste noire", "Il existe " & $RowCount & " lignes dans le fichier")
_Excel_BookSaveAs($oWorkbook, $path & $Res & "ssh_exclus1.csv", "csv",true)
_Excel_BookClose($oWorkbook)

Re: [R] fermer un fichier excel

Posté : mar. 22 juil. 2014 19:46
par orax
Je ne pense pas que "csv" soit un format. Dans la doc pour _Excel_BookSaveAs()
$iFormat [optional] Excel writeable filetype. Can be any value of the XlFileFormat enumeration.

Starting with Excel 2007 you have to provide both the $iFormat parameter and the correct file extension in $sFilePath.
E.g. $iFormat = $xlExcel8 and extension = "xlsx" will return an error.
Please see the XlFileFormat enumeration in ExcelConstants.au3 for possible values.

Code : Tout sélectionner

; XlFileFormat Enumeration. Specifies the file format when saving the worksheet.
; See: http://msdn.microsoft.com/en-us/library/ff198017(v=office.14).aspx
[...]
Global Const $xlCSV = 6 ; CSV
Global Const $xlCSVMac = 22 ; Macintosh CSV
Global Const $xlCSVMSDOS = 24 ; MSDOS CSV
Global Const $xlCSVWindows = 23 ; Windows CSV