Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have been using a macro (run within powerpoint) to build a chart report using multiple chart templates. This used to work fine, but now the charts no longer copy across. Here is the macro below:
Sub Test()
Dim xlApp As Object
Dim xlWrkBook As Object
Dim lCurrSlide As LongSet xlApp = CreateObject("Excel.Application")
Set xlWrkBook = xlApp.Workbooks.Open("C:\Charting\Charts.xls")
Position = 2
Id = 1
Do Until Id = 999
xlWrkBook.Worksheets("Title").Range("SLIDE_INDEX").Value = Id
If xlWrkBook.Worksheets("Title").Range("CHART_TYPE").Value = "Title" Then
lCurrSlide = ActiveWindow.Selection.SlideRange.SlideNumber
xlWrkBook.Worksheets("Title").Range("B8:L67").CopyPicture
ActivePresentation.Slides(lCurrSlide).Shapes.Paste
ActiveWindow.Selection.SlideRange.Shapes.SelectAll
With ActiveWindow.Selection.ShapeRange
End With
lCurrSlide = ActiveWindow.Selection.SlideRange.SlideNumber
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=Position, Layout:=ppLayoutText).SlideIndex
ActiveWindow.Selection.SlideRange.Layout = ppLayoutBlank
Position = Position + 1
End If
If xlWrkBook.Worksheets("Title").Range("CHART_TYPE").Value = "Multi" Then
lCurrSlide = ActiveWindow.Selection.SlideRange.SlideNumber
xlWrkBook.Worksheets("Multi").Range("B8:L67").CopyPicture
ActivePresentation.Slides(lCurrSlide).Shapes.Paste
ActiveWindow.Selection.SlideRange.Shapes.SelectAll
With ActiveWindow.Selection.ShapeRange
End With
lCurrSlide = ActiveWindow.Selection.SlideRange.SlideNumber
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=Position, Layout:=ppLayoutText).SlideIndex
ActiveWindow.Selection.SlideRange.Layout = ppLayoutBlank
Position = Position + 1
End If
If xlWrkBook.Worksheets("Title").Range("CHART_TYPE").Value = "End" Then
Exit Do
End If
Id = Id + 1
Loop
xlWrkBook.Close (True)
xlApp.QuitSet xlApp = Nothing
Set xlWrkBook = NothingEnd Sub

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |