Bonjour à tous,
je développe actuellement (en VB6) une application permettant de transferer automatiquement des graphiques issus d'un fichier Excel (.xls) vers un fichier PowerPoint (.ppt). J'arrive à transferer un graphique et à le mettre la ou je désire l'insérer dans mon ppt.
Cependant, le fichier Excel possédent des macros complémentaires qui permettent de mettre a jour le graphique (au niveau des courbes, des axes des abscisses et des ordonnées). Et je n'arrive pas à activer ces macros complémentaires par le code.
Mon code marche, mais le graphique n'est pas a jour. Voici mon code :
Pour information : Lorsque j'ouvre mon fichier Excel, une boite de dialogue me demande si je veux activer ou non les macros. Alors que lorsque je passe par mon application VB6, le code lance le fichier Excel en question mais aucune boite de dialogue apparait.
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 Private Sub btnTraiter_Click() Dim xlsApp As Excel.Application Dim xlsBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim pptApp As PowerPoint.Application Dim pptPoint As PowerPoint.Presentation Dim nbShpe As Byte If tbXls.Text <> "" And tbPpt.Text <> "" Then 'Xls Set xlsApp = New Excel.Application Set xlsBook = xlsApp.Workbooks.Open(tbXls.Text) Set xlSheet = xlsBook.Worksheets("CR") xlsApp.Visible = True 'Ppt Set pptApp = New PowerPoint.Application pptApp.Visible = True Set pptPoint = pptApp.Presentations.Open(tbPpt.Text) Set xlSheet = xlsBook.Worksheets("CR") 'xlSheet.Cells(4, 1).Value = "CATP" 'If xlSheet.Cells(4, 1).Value = "CATP" Then Call positionGraph Range("C3:H16").Select Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture With pptPoint.Slides(3) .Select .Shapes.Paste.Select End With pptApp.ActiveWindow.Selection.ShapeRange.Left = 5 pptApp.ActiveWindow.Selection.ShapeRange.Top = 270 'End If Else MsgBox "Veuillez séléctionner un fichier Excel (.xls)" Exit Sub End If Application.DisplayAlerts = False Set xlSheet = Nothing Set xlsBook = Nothing Set xlsApp = Nothing 'Excel.Application.Quit Set pptPoint = Nothing Set pptApp = Nothing 'PowerPoint.Application.Quit MsgBox "Transfert Excel --> PowerPoint OK", vbInformation, "Tableau de bord BAM" End Sub Sub positionGraph() With ActiveSheet.ChartObjects(1) .Left = Range("C3:H16").Left .Top = Range("C3:H16").Top .Width = Range("C3:H16").Width .Height = Range("C3:H16").Height End With End Sub
Cordialement.
Partager