PowerPoint shapeId/ShapeName property changes/Increments automatically

A

Abhishek Bagga

I am accessing the properties of the borders of a table
inserted within ppt
presentation but facing this very annoying problem.
Whenever i access any property related to the borders of
the table it
changes/Increments the ID as well as the shape of the
current cell.
This has become a major problem since i am refering to the
current shape
thru a variable and when the id changes the my code gives
me a com exception.
I am facing this problem with both off2k (Only shape name
as Shape Id does
not exists) and off XP
I am posting a small sample code to better explain my
problem
You can create a simple 3X3 table and select the table and
chk this code
thru VB editor inside PPT
I am actually creating my app in .net but for testing
purposes i am posting
the vba code

Sub Testing()
With ActiveWindow.Selection.ShapeRange(1).Table.Cell
(1, 1)
MsgBox ActiveWindow.Selection.ShapeRange(1).Id
MsgBox ActiveWindow.Selection.ShapeRange(1).Name
MsgBox .Borders(ppBorderTop).Visible
MsgBox ActiveWindow.Selection.ShapeRange(1).Id
MsgBox ActiveWindow.Selection.ShapeRange(1).Name
MsgBox .Borders(ppBorderTop).Visible
MsgBox ActiveWindow.Selection.ShapeRange(1).Id
MsgBox ActiveWindow.Selection.ShapeRange(1).Name
MsgBox .Borders(ppBorderTop).Visible
MsgBox ActiveWindow.Selection.ShapeRange(1).Id
MsgBox ActiveWindow.Selection.ShapeRange(1).Name
MsgBox .Borders(ppBorderTop).Visible
MsgBox ActiveWindow.Selection.ShapeRange(1).Id
MsgBox ActiveWindow.Selection.ShapeRange(1).Name
End With
End Sub

Kindly give some suggestion or a solution to this or a
link to some other
similar post that would be of some help
 
S

Shyam Pillai

Hello Abhishek,
While I've encountered the issue you've mentioned in the past, I haven't
experieced in refering to the shape if the reference is stored in a shape
type variable even when the shape name/id changes.
 
S

Shyam Pillai

Hello Abhishek,
While I've encountered the issue you've mentioned in the past, I haven't
experienced an issue in refering to the shape if the reference is stored in
a shape type variable even when the shape name/id changes.
 
S

Steve Rindsberg

Odd. I suspect it's because internally the table is a grouped set of shapes
and perhaps PPT internally ungroups, changes then regroups it whenever you
alter its properties. Obviously, it shouldn't.

If the problem is that you need to be able to reference the table later by the
same shape name as before, try this:

Sub TestAgain()
Dim x As Long
Dim y As Long
Dim oSh As Shape
Dim sShapeName As String

Set oSh = ActiveWindow.Selection.ShapeRange(1)
sShapeName = oSh.Name

For x = 1 To oSh.Table.Columns.Count
For y = 1 To oSh.Table.Rows.Count
oSh.Table.Cell(y, x).Borders(ppBorderTop).Visible = msoTrue
Next y
Next x

oSh.Name = sShapeName

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top