Using "Msgbox" function to show me what objects I am selecting

DataChick

New member
Local time
Tomorrow, 03:16
Joined
Feb 27, 2010
Messages
9
Hi There,

I have created a code that will delete objects from a PPTX in 2007 however there are a couple of objects I don't want to delete. To test this, I need to use the "msgbox" function to show me what object I am selecting - I am using the code below. Can someone tell me what I am doing wrong for the msgbox not to appear and tell me the object type i have selected?

Thanks!!

Public pptApp As Object

Sub Start_PPT()
Set pptApp = CreateObject("powerpoint.application")
End Sub
Sub Delete()

Dim i, j, iShapeCount As Integer

Start_PPT
With pptApp
.Visible = True
For i = 4 To .ActivePresentation.Slides.Count
.ActivePresentation.Slides(i).Select
iShapeCount = .ActiveWindow.Selection.SlideRange.Shapes.Count
For j = iShapeCount To 1 Step -1
'For j = 1 To ActiveWindow.Selection.SlideRange.Shapes.Count
'Do While i <> 200
' On Error Resume Next
ActiveWindow.Selection.SlideRange.Shapes(i).select
Msgbox ActiveWindow.Selection.SlideRange.Shapes(j).Type <--- here is the error
' If .ActiveWindow.Selection.SlideRange.Shapes(j).Type = 13
' .ActiveWindow.Selection.SlideRange.Shapes(j).Select

'ActiveWindow.Selection.SlideRange.Shapes(j).Delete

'i = i + 1
End If
'Loop
Next j
Next i
End With
makePowerPoint
End Sub
 
Hi,

is this an access question? all seems directed around pp...... as i dont do pp i can only hazard a couple of things-

A. you code currently has an "End If" active even though your "If" is commented out.
B. maybe you have to break out the object types for the messagebox to evaluate. it certainly looks like you are wanting the message box to show the file type of the object you are looping through. have you tried saving this to a variable and getting the msgbox to loop this instead?


regs


NS
 
Also, I don't know much about ppt objects but there are times you are working with an "ActiveWindow" object with the dot "." in front of the object and other times you are not. My assumption is that "ActiveWindow" is a property or other member of a "powerpoint.application" and thus, you should always have "." in front of it since you are in the middle of an active "With" block (".ActiveWindow").

Of course, if this is the problem, I would have expected you to see it on the line before the line you're showing you have problems on.

Ditto on the End If. I'm surprised this compiled.
 
And, the "for j=1 to .... " is commented out, you're erroring on a line that has a j in brackets, could that be part of the problem too?
 
Good spot JamesMcS.

DataChick: Could you please tell us the exact error message that is displayed?
 

Users who are viewing this thread

Back
Top Bottom