win32com ppt embedded object
Ryan Ginstrom
software at ginstrom.com
Tue Jul 10 18:49:29 EDT 2007
> On Behalf Of Lance Hoffmeyer
> for Z in WB.Slides(29).Shapes:
> if (Z.Type== 7):
> ZZ=Z.OLEFormat.Object
> WSHEET = ZZ.Worksheets(1)
> WSHEET.Range("A1").Value = .50
> WSHEET.Range("A1").NumberFormat="0%"
I think you need to call Activate on your OLE object.
Here is some code I use to extract the text from an Excel worksheet embedded
in a PowerPoint slide. Maybe you can adapt it to your purposes.
def extract_excel_text( shape ):
"""Process embedded excel worksheet in the powerpoint slide
"""
format = shape.OLEFormat
format.Activate()
excel = format.Object
sheet = excel.ActiveSheet
for row in sheet.UsedRange.Value:
for cell in row:
if cell:
yield cell
for shape in sheet.Shapes:
try:
# We need to give a range of characters, #
# but we can take advantage of the fact that texboxes #
# have a maximum length of 255 characters #
yield shape.TextFrame.Characters(1,255).Text
except com_error, details:
log_error( "Exception getting shape text", details )
Regards,
Ryan
--
Ryan Ginstrom
More information about the Python-list
mailing list