Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > win32com ppt embedded object numbers reverting back to original numbers

Reply
Thread Tools

win32com ppt embedded object numbers reverting back to original numbers

 
 
Lance Hoffmeyer
Guest
Posts: n/a
 
      07-19-2007
Hey all,

I have a script that takes numbers from XL and inserts them into an embedded
MSGRAPH dataset in PPT. The problem is that when I reopen the modified document
that has been saved as a new filename and activate the embedded datasheet the
new numbers that were inserted disappear and the old, original numbers come back?


I thought that adding these lines and resetting these variables was supposed to prevent
this from happening?

del oGraph
del PWB
del oHEADER
del oVALUE

Anyone had experience with this and know what I need to do to keep the embedded datasheet
from reverting back to it's original numbers after modification?

Thanks in advance,

Lance





################################################## ################################################## ################################################## ###########################
################################################## ################################################## ################################################## ###########################
# ADD THIS INTO A MODULE IN PPT TO OBTAIN THE PROG ID OF A SLIDE
#Sub test()
#MsgBox "The Slide ID of the current slide is:" & _
# ActiveWindow.View.Slide.SlideID
#End Sub
################################################## ################################################## ################################################## ###########################
def attributesbyID(row,base,slideID,spreadsheet):
sh = wb.Worksheets (spreadsheet)
sh.Select()
LIST = xlparams(row, base)
################ POWERPOINT SECTION ######################
for shape in WB.Slides.FindBySlideID(slideID).Shapes:
if (shape.Type== 7):
for oXLROW,oXLBASE,oXLLASTCOL,oPPTCELL,oPPTHEADERCELL in LIST:
oVALUE = sh.Cells(oXLROW,oXLLASTCOL).Value
oHEADER = sh.Cells(base-1,oXLLASTCOL).Value + " (n=" + str(int(sh.Cells(oXLBASE,oXLLASTCOL).Value)) + ")"
PWB = WB.Slides.FindBySlideID(slideID).Shapes(shape.Name )
oGraph = PWB.OLEFormat.Object
oGraph.Application.datasheet.Range(oPPTCELL).Value = oVALUE
oGraph.Application.datasheet.Range(oPPTHEADERCELL) .Value = oHEADER
oGraph.Application.datasheet.Font.Bold=False
del oGraph
del PWB
del oHEADER
del oVALUE
################################################## #########
################################################## ################################################## ################################################## ###########################
################################################## ################################################## ################################################## ###########################
################################################## ################################################## ################################################## ###########################

def xlparams(row, base):
lastcol=LASTCOL
############### EXCEL SECTION TO GET NUMBERS #############
thelist=((row,base,lastcol,"A13","013"),(row,base, lastcol-1,"A14","014"),(row,base,lastcol-2,"A15","015"),(row,base,lastcol-3,"A16","016"),
(row+20,base+20,lastcol,"A9","09"),(row+20,base+20 ,lastcol-1,"A10","010"),(row+20,base+20,lastcol-2,"A11","011"),(row+20,base+20,lastcol-3,"A12","012"),
(row+40,base+40,lastcol,"A5","05"),(row+40,base+40 ,lastcol-1,"A6","06" ), (row+40,base+40,lastcol-2,"A7","07" ), (row+40,base+40,lastcol-3,"A8","08" ),
(row+60,base+60,lastcol,"A1","01"),(row+60,base+60 ,lastcol-1,"A2","02" ), (row+60,base+60,lastcol-2,"A3","03" ), (row+60,base+60,lastcol-3,"A4","04" ))
################################################## ########
return thelist


## attribute(ROW NUMBER, BASE ROW NUMBER, SLIDE NUMBER)
attributesbyID(14,12,839,"Attributes(116-144)") # This medication has a convenient dosing frequency
 
Reply With Quote
 
 
 
 
kyosohma@gmail.com
Guest
Posts: n/a
 
      07-20-2007
On Jul 19, 4:33 pm, Lance Hoffmeyer <(E-Mail Removed)> wrote:
> Hey all,
>
> I have a script that takes numbers from XL and inserts them into an embedded
> MSGRAPH dataset in PPT. The problem is that when I reopen the modified document
> that has been saved as a new filename and activate the embedded datasheet the
> new numbers that were inserted disappear and the old, original numbers come back?
>
> I thought that adding these lines and resetting these variables was supposed to prevent
> this from happening?
>
> del oGraph
> del PWB
> del oHEADER
> del oVALUE
>
> Anyone had experience with this and know what I need to do to keep the embedded datasheet
> from reverting back to it's original numbers after modification?
>
> Thanks in advance,
>
> Lance
>
> ################################################## ################################################## ################################################## ###########################
> ################################################## ################################################## ################################################## ###########################
> # ADD THIS INTO A MODULE IN PPT TO OBTAIN THE PROG ID OF A SLIDE
> #Sub test()
> #MsgBox "The Slide ID of the current slide is:" & _
> # ActiveWindow.View.Slide.SlideID
> #End Sub
> ################################################## ################################################## ################################################## ###########################
> def attributesbyID(row,base,slideID,spreadsheet):
> sh = wb.Worksheets (spreadsheet)
> sh.Select()
> LIST = xlparams(row, base)
> ################ POWERPOINT SECTION ######################
> for shape in WB.Slides.FindBySlideID(slideID).Shapes:
> if (shape.Type== 7):
> for oXLROW,oXLBASE,oXLLASTCOL,oPPTCELL,oPPTHEADERCELL in LIST:
> oVALUE = sh.Cells(oXLROW,oXLLASTCOL).Value
> oHEADER = sh.Cells(base-1,oXLLASTCOL).Value + " (n=" + str(int(sh.Cells(oXLBASE,oXLLASTCOL).Value)) + ")"
> PWB = WB.Slides.FindBySlideID(slideID).Shapes(shape.Name )
> oGraph = PWB.OLEFormat.Object
> oGraph.Application.datasheet.Range(oPPTCELL).Value = oVALUE
> oGraph.Application.datasheet.Range(oPPTHEADERCELL) .Value = oHEADER
> oGraph.Application.datasheet.Font.Bold=False
> del oGraph
> del PWB
> del oHEADER
> del oVALUE
> ################################################## #########
> ################################################## ################################################## ################################################## ###########################
> ################################################## ################################################## ################################################## ###########################
> ################################################## ################################################## ################################################## ###########################
>
> def xlparams(row, base):
> lastcol=LASTCOL
> ############### EXCEL SECTION TO GET NUMBERS #############
> thelist=((row,base,lastcol,"A13","013"),(row,base, lastcol-1,"A14","014"),(row,base,lastcol-2,"A15","015"),(row,base,lastcol-3,"A16","016"),
> (row+20,base+20,lastcol,"A9","09"),(row+20,base+20 ,lastcol-1,"A10","010"),(row+20,base+20,lastcol-2,"A11","011"),(row+20,base+20,lastcol-3,"A12","012"),
> (row+40,base+40,lastcol,"A5","05"),(row+40,base+40 ,lastcol-1,"A6","06" ), (row+40,base+40,lastcol-2,"A7","07" ), (row+40,base+40,lastcol-3,"A8","08" ),
> (row+60,base+60,lastcol,"A1","01"),(row+60,base+60 ,lastcol-1,"A2","02" ), (row+60,base+60,lastcol-2,"A3","03" ), (row+60,base+60,lastcol-3,"A4","04" ))
> ################################################## ########
> return thelist
>
> ## attribute(ROW NUMBER, BASE ROW NUMBER, SLIDE NUMBER)
> attributesbyID(14,12,839,"Attributes(116-144)") # This medication has a convenient dosing frequency


I've never done this with Python, but it sounds like your inserting a
linked table rather than a copy of the dataset as an Excel worksheet.
Try doing the insert manually to see which way keeps the data the way
you want, then you'll probably gain insight into what you need to do
in Python.

Mike

 
Reply With Quote
 
 
 
 
Lance Hoffmeyer
Guest
Posts: n/a
 
      07-26-2007
Hey all,

I solved this problem. Here is the final version of this def for anyone who
someday may be interested:

def attributesbyID(row,base,slideID,spreadsheet):
sh = wb.Worksheets (spreadsheet)
sh.Select()
LIST = xlparams(row, base)
################ POWERPOINT SECTION ######################
for shape in WB.Slides.FindBySlideID(slideID).Shapes:
if (shape.Type== 7):
for oXLROW,oXLBASE,oXLLASTCOL,oPPTCELL,oPPTHEADERCELL in LIST:
oVALUE = sh.Cells(oXLROW,oXLLASTCOL).Value
oHEADER = sh.Cells(base-1,oXLLASTCOL).Value + " (n=" + str(int(sh.Cells(oXLBASE,oXLLASTCOL).Value)) + ")"
PWB = WB.Slides.FindBySlideID(slideID).Shapes(shape.Name )
oGraph = PWB.OLEFormat.Object
# oGraph = shape.OLEFormat.Object
oGraph.Application.datasheet.Range(oPPTCELL).Value = oVALUE
oGraph.Application.datasheet.Range(oPPTHEADERCELL) .Value = oHEADER
oGraph.Application.datasheet.Font.Bold=False
oGraph.Application.Update()
oGraph.Application.Quit()
del oGraph
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
win32com ppt saveas, not allowing spaces? Lance Hoffmeyer Python 3 07-23-2007 07:57 PM
win32com ppt embedded object Lance Hoffmeyer Python 2 07-11-2007 09:14 PM
Reverting files back to open with "unknown application"? unglee Computer Support 0 10-16-2006 12:05 PM
Reverting back to old OE without formatting harddrive. Lee Davison Computer Support 1 02-11-2004 08:19 PM
Win32::OLE adding shape to OLE Object (xlsheet) in PPT Lance Hoffmeyer Perl Misc 0 11-17-2003 07:44 PM



Advertisments