Computing.Net > Forums > Programming > Powerpoint/Excel Macro

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Powerpoint/Excel Macro

Reply to Message Icon

Name: Debi
Date: January 9, 2009 at 08:49:23 Pacific
OS: Windows Vista
CPU/Ram: Core2 Duo 2GB
Product: Dell / 745
Subcategory: General
Comment:

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 Long

Set 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.Quit

Set xlApp = Nothing
Set xlWrkBook = Nothing

End Sub



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Powerpoint/Excel Macro

Can I call an Excel macro from cell www.computing.net/answers/programming/can-i-call-an-excel-macro-from-cell/4812.html

Excel macro www.computing.net/answers/programming/excel-macro/9408.html

Excel Macro www.computing.net/answers/programming/excel-macro/14702.html