Bonjour à tous,

Dans une appli type web, je dois générer un fichier Excel provenant d'un modèle (avec multiples onglets) mais ne contenant qu'un onglet (en fonction des droits des utilisateurs).

J'ai donc fait ceci... mais impossible de trouver comment supprimer les onglets non nécessaires :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<cfset onglet = "test">
<cfset w_date_jour = dateformat(now(),"yyyymmdd")>
			
<CFTRY>
   <CFOBJECT        
	ACTION="CONNECT"
	CLASS="Excel.Application"
	NAME="objExcel"
	TYPE="COM">
<CFCATCH>
   <CFOBJECT
	ACTION="CREATE"
	CLASS="Excel.Application"
	NAME="objExcel"
	TYPE="COM">
</CFCATCH>			   
</CFTRY>
			
<!---Création du fichier Excel --->
<cfscript>
	objExcel.Visible = false;
	objExcel.DisplayAlerts = false;  
				
        // Ouverture du fichier source
	objWorkBook_temp = objExcel.Workbooks.Open("#application.temp#\mon_modele_excel.xls");
	objWorkSheets_temp = objExcel.WorkSheets;
	numOfSheets = objWorkSheets_temp.Count;
	
        for(w=numOfSheets; w gt 1; w=w-1){
		objWorkSheet_temp = objWorkSheets_temp.Item(val(w));			
					
		if(objWorkSheet_temp.Name neq #onglet#){
			//objWorkSheet_temp.Delete();
		        objWorkSheets_temp.Item(objWorkSheet_temp.Name).Delete();
		}
	}
				
	fic = "#application.temp#\mon_fichier_" & #w_date_jour# & ".xls";
	objWorkBook_temp.SaveAs(fic2,Val(1));
	objWorkBook_temp.Close();
	objexcel.quit();
	ReleaseComObject(objexcel);
</cfscript>
Et j'ai cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
An exception occurred when accessing a Com object field.  
The cause of this exception was that: AutomationException: 0x800a01a8 - .
Merci d'avance à tous