win32com ppt embedded object numbers reverting back to original numbers

Discussion in 'Python' started by Lance Hoffmeyer, Jul 19, 2007.

  1. 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
    Lance Hoffmeyer, Jul 19, 2007
    #1
    1. Advertising

  2. Lance Hoffmeyer

    Guest

    On Jul 19, 4:33 pm, Lance Hoffmeyer <> 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
    , Jul 20, 2007
    #2
    1. Advertising

  3. Re: win32com ppt embedded object numbers reverting back to originalnumbers - SOLVED

    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
    Lance Hoffmeyer, Jul 26, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sheikh Nabeel Moeen

    reverting to .NET Framework 1.1 from 2.0

    Sheikh Nabeel Moeen, Oct 29, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    576
    Sheikh Nabeel Moeen
    Oct 29, 2004
  2. Dave
    Replies:
    0
    Views:
    1,518
  3. Lance Hoffmeyer

    win32com ppt embedded object

    Lance Hoffmeyer, Jul 10, 2007, in forum: Python
    Replies:
    2
    Views:
    662
    Lance Hoffmeyer
    Jul 11, 2007
  4. Lance Hoffmeyer

    win32com ppt saveas, not allowing spaces?

    Lance Hoffmeyer, Jul 16, 2007, in forum: Python
    Replies:
    3
    Views:
    501
    supercooper
    Jul 23, 2007
  5. Lance Hoffmeyer
    Replies:
    0
    Views:
    238
    Lance Hoffmeyer
    Nov 17, 2003
Loading...

Share This Page