Copie de plusieurs graphs Excel sur une meme slide Powerpoint
1 réponse
uwaga
Bonjour,
Je souhaite copier des graphiques d'Excel vers Powerpoint a raison de
4 graphiques par slide et me heurte a 2 problemes. J'ai trouve une
macro qui fonctionne (http://cjoint.com/?hDpv1e2Uts). Je la
"comprends" en la lisant mais suis incapable de la modifier sans
aide :
1- Les numeros d'index de mes slides sont "en desordre". Comment
s'assurer que les graphs selectionnes respectent bien un ordre 1,2,3,4
- 1,2,3,4... Peut on changer les numeros d'index lors l'instruction
"Graphcount = Worksheets("nom de la feuille").ChartObjects.Count" ? A
propos, peut on compter tous les graphs d'un classeur et non
uniquement de la feuille ?
2- La boucle qui copie les graphs vers powerpoint creee 1 diapo par
graph. J'en souhaiterais 4. Connaitriez vous la formule ? (pour les
positions et taille sur la slide, je vois quelles instructions
modifier)
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Christophe Mathon
Bonjour Uwaga,
Il y a une erreur dans la macro de base: Do While i < Graphcount ' starts a loop to copy charts devrai etre: Do While i <= Graphcount ' starts a loop to copy charts
1- Les numeros d'index de mes slides sont "en desordre". Comment s'assurer que les graphs selectionnes respectent bien un ordre 1,2,3,4 - 1,2,3,4... Peut on changer les numeros d'index lors l'instruction "Graphcount = Worksheets("nom de la feuille").ChartObjects.Count" ?
Je ne conprend pas vraiment l'explication (meme avec mon cafe du matin lol). Peu tu etre plus explisite? (avec un exemple, des screenshot et un fichier exel c'est le top)
A propos, peut on compter tous les graphs d'un classeur et non uniquement de la feuille ?
For i = 1 To Pages Graphcount = Graphcount + Worksheets(i).ChartObjects.Count Next <><><><><><><><><><>
2- La boucle qui copie les graphs vers powerpoint creee 1 diapo par graph. J'en souhaiterais 4. Connaitriez vous la formule ? (pour les positions et taille sur la slide, je vois quelles instructions modifier)
<><><><><><><><><><> Sub CreateNewPowerPointPresentation() ' to test this code, paste it into an Excel module ' add a reference to the PowerPoint-library this is done from the Tools ---> References menu path and you 'need to find the microsoft powerpoint check box and check it. Then excel can use ppt objects within itself Dim pptApp As PowerPoint.Application Dim pptPres As PowerPoint.Presentation Dim pptSlide As PowerPoint.Slide Dim pptShape As PowerPoint.Shape Dim i As Integer, strString As String Dim Graphcount As Integer Count = 0 'initialise count variable i = 1 'returns the number of charts on the sheet at the time the macro is run. 'User customises the worksheets name to sheet that holds all the charts Graphcount = Worksheets(1).ChartObjects.Count MsgBox Graphcount Set pptApp = CreateObject("PowerPoint.Application") Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a new presentation ' or open an existing presentation ' Set pptPres = pptApp.Presentations.Open("C:FoldernameFilename.ppt")
Do While i <= Graphcount ' starts a loop to copy charts With pptPres.Slides Set pptSlide = .Add(.Count + 1, ppLayoutTitleOnly) ' add a slide End With For forChart = 1 To 4 ActiveSheet.ChartObjects(i).Activate ' selects the chart object by its index number ActiveChart.ChartArea.Select ActiveChart.ChartArea.Copy
With pptSlide .Shapes(1).TextFrame.TextRange.Text = "Slide Title" 'edit to put a generic title on each slide or ' take this line out if you dont want a generic slide title to appear on each slide .Shapes.PasteSpecial ppPasteDefault With .Shapes(.Shapes.Count) ' sizes the graph on the slide .Left = 120 .Top = 125.125 .Width = 480 .Height = 289.625 End With End With
Application.CutCopyMode = False ' end cut/copy from Excel i = i + 1 If (i > Graphcount) Then Exit For End If Next 'i = i + 1 ' increment the graph count to copy the next chart on the excel sheet Set pptSlide = Nothing Loop
On Error Resume Next ' ignore errors On Error GoTo 0 ' resume normal error handling Set pptPres = Nothing
pptApp.Visible = True ' display the application 'pptApp.Quit ' or close the PowerPoint application Set pptApp = Nothing End Sub <><><><><><><><><><>
Je souhaite copier des graphiques d'Excel vers Powerpoint a raison de 4 graphiques par slide et me heurte a 2 problemes. J'ai trouve une macro qui fonctionne (http://cjoint.com/?hDpv1e2Uts). Je la "comprends" en la lisant mais suis incapable de la modifier sans aide :
1- Les numeros d'index de mes slides sont "en desordre". Comment s'assurer que les graphs selectionnes respectent bien un ordre 1,2,3,4 - 1,2,3,4... Peut on changer les numeros d'index lors l'instruction "Graphcount = Worksheets("nom de la feuille").ChartObjects.Count" ? A propos, peut on compter tous les graphs d'un classeur et non uniquement de la feuille ?
2- La boucle qui copie les graphs vers powerpoint creee 1 diapo par graph. J'en souhaiterais 4. Connaitriez vous la formule ? (pour les positions et taille sur la slide, je vois quelles instructions modifier)
Je vous remercie pour vos eclairages,
Bonjour Uwaga,
Il y a une erreur dans la macro de base:
Do While i < Graphcount ' starts a loop to copy charts
devrai etre:
Do While i <= Graphcount ' starts a loop to copy charts
1- Les numeros d'index de mes slides sont "en desordre". Comment
s'assurer que les graphs selectionnes respectent bien un ordre 1,2,3,4
- 1,2,3,4... Peut on changer les numeros d'index lors l'instruction
"Graphcount = Worksheets("nom de la feuille").ChartObjects.Count" ?
Je ne conprend pas vraiment l'explication (meme avec mon cafe du matin lol).
Peu tu etre plus explisite? (avec un exemple, des screenshot et un fichier
exel c'est le top)
A propos, peut on compter tous les graphs d'un classeur et non
uniquement de la feuille ?
For i = 1 To Pages
Graphcount = Graphcount + Worksheets(i).ChartObjects.Count
Next
<><><><><><><><><><>
2- La boucle qui copie les graphs vers powerpoint creee 1 diapo par
graph. J'en souhaiterais 4. Connaitriez vous la formule ? (pour les
positions et taille sur la slide, je vois quelles instructions
modifier)
<><><><><><><><><><>
Sub CreateNewPowerPointPresentation()
' to test this code, paste it into an Excel module
' add a reference to the PowerPoint-library this is done from the
Tools ---> References menu path and you
'need to find the microsoft powerpoint check box and check it. Then
excel can use ppt objects within itself
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSlide As PowerPoint.Slide
Dim pptShape As PowerPoint.Shape
Dim i As Integer, strString As String
Dim Graphcount As Integer
Count = 0 'initialise count variable
i = 1
'returns the number of charts on the sheet at the time the macro is run.
'User customises the worksheets name to sheet that holds all the charts
Graphcount = Worksheets(1).ChartObjects.Count
MsgBox Graphcount
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a new
presentation
' or open an existing presentation
' Set pptPres = pptApp.Presentations.Open("C:FoldernameFilename.ppt")
Do While i <= Graphcount ' starts a loop to copy charts
With pptPres.Slides
Set pptSlide = .Add(.Count + 1, ppLayoutTitleOnly) ' add a slide
End With
For forChart = 1 To 4
ActiveSheet.ChartObjects(i).Activate ' selects the chart object
by its index number
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
With pptSlide
.Shapes(1).TextFrame.TextRange.Text = "Slide Title" 'edit to
put a generic title on each slide or
' take this line out if you dont want a generic slide title
to appear on each slide
.Shapes.PasteSpecial ppPasteDefault
With .Shapes(.Shapes.Count) ' sizes the graph on the slide
.Left = 120
.Top = 125.125
.Width = 480
.Height = 289.625
End With
End With
Application.CutCopyMode = False ' end cut/copy from Excel
i = i + 1
If (i > Graphcount) Then
Exit For
End If
Next
'i = i + 1 ' increment the graph count to copy the next chart on the
excel sheet
Set pptSlide = Nothing
Loop
On Error Resume Next ' ignore errors
On Error GoTo 0 ' resume normal error handling
Set pptPres = Nothing
pptApp.Visible = True ' display the application
'pptApp.Quit ' or close the PowerPoint application
Set pptApp = Nothing
End Sub
<><><><><><><><><><>
"uwaga" <hervefiles@gmail.com> wrote in message
news:09955d4a-90df-4a97-ae28-a77236f08acc@34g2000hsf.googlegroups.com...
Bonjour,
Je souhaite copier des graphiques d'Excel vers Powerpoint a raison de
4 graphiques par slide et me heurte a 2 problemes. J'ai trouve une
macro qui fonctionne (http://cjoint.com/?hDpv1e2Uts). Je la
"comprends" en la lisant mais suis incapable de la modifier sans
aide :
1- Les numeros d'index de mes slides sont "en desordre". Comment
s'assurer que les graphs selectionnes respectent bien un ordre 1,2,3,4
- 1,2,3,4... Peut on changer les numeros d'index lors l'instruction
"Graphcount = Worksheets("nom de la feuille").ChartObjects.Count" ? A
propos, peut on compter tous les graphs d'un classeur et non
uniquement de la feuille ?
2- La boucle qui copie les graphs vers powerpoint creee 1 diapo par
graph. J'en souhaiterais 4. Connaitriez vous la formule ? (pour les
positions et taille sur la slide, je vois quelles instructions
modifier)
Il y a une erreur dans la macro de base: Do While i < Graphcount ' starts a loop to copy charts devrai etre: Do While i <= Graphcount ' starts a loop to copy charts
1- Les numeros d'index de mes slides sont "en desordre". Comment s'assurer que les graphs selectionnes respectent bien un ordre 1,2,3,4 - 1,2,3,4... Peut on changer les numeros d'index lors l'instruction "Graphcount = Worksheets("nom de la feuille").ChartObjects.Count" ?
Je ne conprend pas vraiment l'explication (meme avec mon cafe du matin lol). Peu tu etre plus explisite? (avec un exemple, des screenshot et un fichier exel c'est le top)
A propos, peut on compter tous les graphs d'un classeur et non uniquement de la feuille ?
For i = 1 To Pages Graphcount = Graphcount + Worksheets(i).ChartObjects.Count Next <><><><><><><><><><>
2- La boucle qui copie les graphs vers powerpoint creee 1 diapo par graph. J'en souhaiterais 4. Connaitriez vous la formule ? (pour les positions et taille sur la slide, je vois quelles instructions modifier)
<><><><><><><><><><> Sub CreateNewPowerPointPresentation() ' to test this code, paste it into an Excel module ' add a reference to the PowerPoint-library this is done from the Tools ---> References menu path and you 'need to find the microsoft powerpoint check box and check it. Then excel can use ppt objects within itself Dim pptApp As PowerPoint.Application Dim pptPres As PowerPoint.Presentation Dim pptSlide As PowerPoint.Slide Dim pptShape As PowerPoint.Shape Dim i As Integer, strString As String Dim Graphcount As Integer Count = 0 'initialise count variable i = 1 'returns the number of charts on the sheet at the time the macro is run. 'User customises the worksheets name to sheet that holds all the charts Graphcount = Worksheets(1).ChartObjects.Count MsgBox Graphcount Set pptApp = CreateObject("PowerPoint.Application") Set pptPres = pptApp.Presentations.Add(msoTrue) ' create a new presentation ' or open an existing presentation ' Set pptPres = pptApp.Presentations.Open("C:FoldernameFilename.ppt")
Do While i <= Graphcount ' starts a loop to copy charts With pptPres.Slides Set pptSlide = .Add(.Count + 1, ppLayoutTitleOnly) ' add a slide End With For forChart = 1 To 4 ActiveSheet.ChartObjects(i).Activate ' selects the chart object by its index number ActiveChart.ChartArea.Select ActiveChart.ChartArea.Copy
With pptSlide .Shapes(1).TextFrame.TextRange.Text = "Slide Title" 'edit to put a generic title on each slide or ' take this line out if you dont want a generic slide title to appear on each slide .Shapes.PasteSpecial ppPasteDefault With .Shapes(.Shapes.Count) ' sizes the graph on the slide .Left = 120 .Top = 125.125 .Width = 480 .Height = 289.625 End With End With
Application.CutCopyMode = False ' end cut/copy from Excel i = i + 1 If (i > Graphcount) Then Exit For End If Next 'i = i + 1 ' increment the graph count to copy the next chart on the excel sheet Set pptSlide = Nothing Loop
On Error Resume Next ' ignore errors On Error GoTo 0 ' resume normal error handling Set pptPres = Nothing
pptApp.Visible = True ' display the application 'pptApp.Quit ' or close the PowerPoint application Set pptApp = Nothing End Sub <><><><><><><><><><>
Je souhaite copier des graphiques d'Excel vers Powerpoint a raison de 4 graphiques par slide et me heurte a 2 problemes. J'ai trouve une macro qui fonctionne (http://cjoint.com/?hDpv1e2Uts). Je la "comprends" en la lisant mais suis incapable de la modifier sans aide :
1- Les numeros d'index de mes slides sont "en desordre". Comment s'assurer que les graphs selectionnes respectent bien un ordre 1,2,3,4 - 1,2,3,4... Peut on changer les numeros d'index lors l'instruction "Graphcount = Worksheets("nom de la feuille").ChartObjects.Count" ? A propos, peut on compter tous les graphs d'un classeur et non uniquement de la feuille ?
2- La boucle qui copie les graphs vers powerpoint creee 1 diapo par graph. J'en souhaiterais 4. Connaitriez vous la formule ? (pour les positions et taille sur la slide, je vois quelles instructions modifier)