Bonjour tout le monde,
j'ai pour projet de faire une application qui crée automatiquement un powerpoint.
Mais j'ai un soucis au niveau de la modification d'un chart qui est dans un template (fichier .pot). Voici un snipped de mon code :
Au niveau de la compilation, je recois cette erreur :
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 // ceci est ma methode pour modifier un slide public void ModifiedSlide3(PowerPoint.Slide objSlide, PowerPoint.Presentations objPresSet, PowerPoint._Presentation objPres, int i, String title) { // instanciation de ma classe Form1 Form1 f = new Form1(); // methode qui contient de methode pour acceder a ma base de donnee Dao d = new Dao(); // Integer i permet de choisir le slide. objSlide = objPres.Slides[i]; int e = f.CountTable(objSlide, i); e = e + 1; objSlide.Shapes.AddTextbox(Core.MsoTextOrientation.msoTextOrientationHorizontal, 3, 90, 125, 95); objTextRng = objSlide.Shapes[e].TextFrame.TextRange; objTextRng.Text = title; objTextRng.Font.Name = "Trebucher MS"; objTextRng.ParagraphFormat.Alignment = Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignCenter; System.Diagnostics.Debug.Write("Counter = "+ e +" \n"); int p = objSlide.Shapes.Count + 1; System.Diagnostics.Debug.Write("La valeur de p : " + p + "\n"); // Selection d'un chart objChart = (Graph.Chart)objSlide.Shapes[1].OLEFormat.Object; datasheet = objChart.Application.DataSheet; datasheet.Cells[7, 7] = "60"; objChart.Application.Update(); }
Mais par contre j'arrive a ajouter un chart grace a ce code :Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Graph.Chart'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208FB-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Avez vous une idée au niveau de l'erreur générée ou un autre moyen de pouvoir modifier un chart avec une autre méthode?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 objChart = (Graph.Chart)objSlide.Shapes.AddOLEObject(150, 150, 480, 320, "MSGraph.Chart.8", "", Core.MsoTriState.msoFalse, "", 0, "", Core.MsoTriState.msoFalse).OLEFormat.Object;
Partager