Log in

View Full Version : Unable to select table



Bercilak
02-20-2010, 09:15 PM
Work mostly in Excel and certainly miss the ability to record. I have a presentation which I am building from a macro. I am using a slide as a section separator and am trying to change the color of the rows. If I manually select the table prior to running the script, everything works as expected, however, if I do not select it first, it does not work.

The error I receive is:

Run-time error '-2147188160 (80048240)
Selection(unknown memeber): Invalud request. Nothing appropriate is currently selected.

Here is my script:


Sub tablecolor()
ActiveWindow.View.GotoSlide (17)
Dim Z As Integer
Z = 5
ActiveWindow.Selection.ShapeRange(1).Select
With ActiveWindow.Selection.ShapeRange(1).Table
.Cell(Z, 1).Shape.Fill.ForeColor.RGB = RGB(111, 131, 68)
.Cell(Z, 2).Shape.Fill.ForeColor.RGB = RGB(111, 131, 68)
End With
End Sub


Does anyone have ANY ideas...I have searched through quite a bit of posts, but nothing describing this error.

Thanks in advance.

John Wilson
02-21-2010, 12:03 PM
ActiveWindow.Selection.ShapeRange1 is going to look for the first selected shape (and it needs to be a table) If nothing appropriate is selected then you will get the error. You do not have to select shapes in PowerPoint to modify them. Try this:

Use the selection pane to name the table to something useful eg mytable and then

Sub table_col()
Dim z As Integer
z = 5
With ActivePresentation.Slides(17).Shapes("mytable").Table
.Cell(z, 1).Shape.Fill.ForeColor.RGB = RGB(111, 131, 68)
.Cell(z, 2).Shape.Fill.ForeColor.RGB = RGB(111, 131, 68)
End With
End Sub

Bercilak
02-21-2010, 01:28 PM
Thank you so very much!! It worked like a charm!!!!

John Wilson
02-22-2010, 01:51 AM
You're welcome!