Johnny C
Well-known Member
- Joined
- Nov 7, 2006
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
I have a utility that copies charts and named ranges into PowerPoint slides.
It worked fine until I added some code to (in bold below) resize the copied Shape and move it on the slide. Now it crashes with a Runtime error: 9 Subscript out of range (on the red line below)
The DoEvents loops just allow PP to do it's stuff before VBA continues. Extraneous stuff has been removed.
strSheet has a valid sheet name.
I tried replacing the offending line with
but the same happens. In the locals window I can see xlApp, within there I can see Activeworkbook, within that I can see Sheets and the sheet with the name in strSheet exists.
What am I doing wrong?
It worked fine until I added some code to (in bold below) resize the copied Shape and move it on the slide. Now it crashes with a Runtime error: 9 Subscript out of range (on the red line below)
The DoEvents loops just allow PP to do it's stuff before VBA continues. Extraneous stuff has been removed.
Code:
Set xlApp = Excel.Application
Set ppApp = GetObject(, "PowerPoint.Application")
Set ppSelected = ppApp.Presentations.Item(intPPCount)
Set activeSlide = ppSelected.Slides(intDocNum)
…
activeSlide.Shapes.PasteSpecial DataType:=ppPasteDefault, Link:=msoTrue
For i = 1 To 5000; DoEvents; Next i
[B]ppApp.ActiveWindow.Selection.ShapeRange.Height = sngHeight
ppApp.ActiveWindow.Selection.ShapeRange.Width = sngWidth
ppApp.ActiveWindow.Selection.ShapeRange.Left = sngLeft
ppApp.ActiveWindow.Selection.ShapeRange.Top = sngTop
[/B]activeSlide.Shapes(activeSlide.Shapes.Count).LinkFormat.BreakLink
For i = 1 To 5000; DoEvents; Next i
activeSlide.Shapes(activeSlide.Shapes.Count).Fill.Solid
activeSlide.Shapes(activeSlide.Shapes.Count).Fill.ForeColor.RGB = RGB(255, 255, 255)
[B][COLOR=#ff0000]Sheets(strSheetName).Activate[/COLOR][/B]
strSheet has a valid sheet name.
I tried replacing the offending line with
Code:
xlApp.ActiveWorkbook.Sheets(strSheetName).Activate
What am I doing wrong?
Last edited: