intimez
Messages postés13Date d'inscriptionlundi 25 décembre 2000StatutMembreDernière intervention 1 mai 2010
-
19 oct. 2009 à 12:29
intimez
Messages postés13Date d'inscriptionlundi 25 décembre 2000StatutMembreDernière intervention 1 mai 2010
-
20 oct. 2009 à 15:22
Bonjour,
j'essaye d'adapter un code macro en vb.net .je voudrais créer un tableau croisé dynamique d'un fichier excel en vb.net. voila le code de macro :
xlApp = New Excel.ApplicationClass
FichierExel = xlApp.Workbooks.Open("C:\Documents and Settings\MyPC1\Bureau\rapporta.xls")
PageExel = FichierExel.Worksheets("Détails")
Dim range As Excel.Range
'____________________________________
PageExel.Select()
FichierExel.Sheets.Add()
FichierExel.Sheets("Feuil1").Select()
FichierExel.Sheets("Feuil1").Name = "pageTableau"
page2 = FichierExel.Worksheets("pageTableau")
PageExel.Select()
PageExel.Range("A532:I544").Select()
PageExel.Range("A532:I544").Copy()
'selection.Copy()
page2.Select()
page2.Range("A2").Select()
page2.Paste()
PageExel.Select()
PageExel.Range("A2:I2").Select()
xlApp.CutCopyMode = False
PageExel.Range("A2:I2").Copy()
page2.Select()
page2.Rows("1:1").Select()
page2.Paste()
page2.Range("A1:I14").Select()
xlApp.CutCopyMode = False
FichierExel.PivotCaches.Add(SourceType:=1, SourceData:= _
"pageTableau!R1C1:R14C9").CreatePivotTable(TableDestination:= _
"[rapporta.xls]pageTableau!R21C2", TableName:="Tableau croisé dynamique1", _
DefaultVersion:=1)
FichierExel.ShowPivotTableFieldList = True
'page2.SmallScroll(Down:=3)
With page2.PivotTables("Tableau croisé dynamique1").PivotFields("Date")
.Orientation = 2
.Position = 1
End With
With page2.PivotTables("Tableau croisé dynamique1").PivotFields("Projet")
.Orientation = 1
.Position = 1
End With
page2.PivotTables("Tableau croisé dynamique1").AddDataField(page2. _
PivotTables("Tableau croisé dynamique1").PivotFields("heures nettes"), _
"Somme de heures nettes", -4157)
FichierExel.ShowPivotTableFieldList = False
xlApp.CommandBars("PivotTable").Visible = False
mais il me génère une exception de :
Paramètre incorrect. (Exception de HRESULT : 0x80070057 (E_INVALIDARG)).
svp aidez moi a ressoude ce problème
Merci
Marroubi
Messages postés51Date d'inscriptionlundi 18 mai 2009StatutMembreDernière intervention30 octobre 20092 20 oct. 2009 à 15:03
En principe un tableau croisé dynamique est lié à un équivallent "source de données".
Cette source est le plus souvent définie sur une feuille spécifique du classeur et associé à un nom de fonction.
En modifiant la source et en mettant à jour le nom on peut peut être obtenir les résulatats attendus.
Je rechercherai à des actions dans cette direction. Et je peux guère t'en dire plus.
intimez
Messages postés13Date d'inscriptionlundi 25 décembre 2000StatutMembreDernière intervention 1 mai 2010 20 oct. 2009 à 15:22
mon prob c'est au niveau de paramètre pas au niveau de la source de donnée .ça en premier temps dans un deuxième temps le code que j'utilise est extrait depuis un macro donc il n'y a pas de problème de la source il obtient le nom de la feuille et aussi le plage des informations.
Merci et j'attends les information de tes recherche seulement je veux vous montrer le problème pour que vous puissiez allez plus loin.