PDA

View Full Version : Prob with vba code in 2007 and giving error after i installed 2010



rahulnath23
01-19-2012, 02:33 AM
Hi,
I had a vba code in excel 2007 for updating ppt from excel. I recently installed office 10 (and also have office 2007) and getting the error on -

Sub PPTgraph(ByVal rngData As Variant, ByVal intSlide As Integer, ByVal strObj As String)
Dim objPPT As PowerPoint.Application
Dim objSlide As PowerPoint.Slide
Dim objShape As PowerPoint.Shape
Set objPPT = CreateObject("Powerpoint.application") ' open powerpoint
objPPT.Visible = True
Set objSlide = objPPT.Presentations(1).Slides(intSlide) ' chart on slide 2
Set objShape = objSlide.Shapes(strObj)
objShape.Chart.ChartData.Activate
Range("A1:A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.Replace What:="CY", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Range("M40").FormulaR1C1 = "1"
Range("M40").Copy
ActiveSheet.UsedRange.Offset(1, 1).Resize(ActiveSheet.UsedRange.Rows.Count - 1, ActiveSheet.UsedRange.Columns.Count - 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlMultiply, SkipBlanks:=False, Transpose:=False
Range("M40").ClearContents
'This is where it gets stuck::dunno
objShape.Chart.ChartData.Workbook.Close
Set objPPT = Nothing
Set objShape = Nothing
Set objSlide = Nothing
End Sub