Exporter automatiquement Excel vers word
o
Bonjour,
J'avais développé cette macro me permettant:
- copier un tableau excel
- coller dans le ppt ouvert après avoir ajouté une page à la suite
- incrémenter mon tableau excel (I2) et coller dans PPT jusqu'à ce que la dernière ligne
Cette macro fonctionne très bien mais maintenant on me demande de faire pareil dans word...(donc avec des sauts de page). Et en plus il faudrait que je puis modifier le texte dans mon word (donc je ne peux pas coller une image). Voici le code de mon excel vers PPT:
Sub Macroautomatique()
'
'
'
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PPTTemp As Object
Set PPTTemp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then PowerpointWasNotRunning = True
Err.Clear
' DetectExcel
PPTTemp.Application.Visible = True
If ExcelWasNotRunning = True Then
PPTTemp.Application.Quit
End If
' Reference instance of PowerPoint
On Error Resume Next
' Check whether PowerPoint is running
Set PPApp = GetObject(, "PowerPoint.Application")
If PPApp Is Nothing Then
' PowerPoint is not running, create new instance
Set PPApp = CreateObject("PowerPoint.Application")
PPApp.Visible = True
End If
On Error GoTo 0
' Reference presentation and slide
On Error Resume Next
If PPApp.Windows.Count > 0 Then
' There is at least one presentation
' Use existing presentation
Set PPPres = PPApp.ActivePresentation
' Use active slide
Set PPSlide = PPPres.Slides _
(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
Else
' There are no presentations
' Create new presentation
Set PPPres = PPApp.Presentations.Add
' Add first slide
'Set PPSlide = PPPres.Slides.Add(1, ppLayoutBlank)
End If
On Error GoTo 0
Dim Derlig As Long
Derlig = Worksheets("données").Range("C" & Cells.Rows.Count).End(xlUp).Row
For i = 3 To Derlig
Worksheets("Export Automatique").Range("I2").Formula = i
'Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
Worksheets("Export Automatique").Range("A1:G21").CopyPicture _
Appearance:=xlScreen, Format:=xlPicture
' Paste chart
PPSlide.Shapes.Paste.Select
' Align pasted chart
PPApp.ActiveWindow.Selection.ShapeRange.Left = 10
PPApp.ActiveWindow.Selection.ShapeRange.Top = 60
PPApp.ActiveWindow.Selection.ShapeRange.Width = 700
Next i
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Submerci d'avance