Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / July 2007

Tip: Looking for answers? Try searching our database.

ppt embedded object numbers reverting back to original numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lance Hoffmeyer - 25 Jul 2007 14:23 GMT
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 doubleclick the embedded datasheet to check the
new numbers they revert back to the original numbers that were present before I modified
them with my script.  I am using python instead of VBA for this because I already have
some other code that was already written in python.

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

del oGraph (Set oGraph = Nothing)
del PWB (Set PWB = Nothing)
del oHEADER (Set oHeader = Nothing)
del oVALUE (Set oValue = Nothing)

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?  Is there something simple
I have missed?  Is there some type of global VBA code I can add to a PPT module to prevent
the modified numbers from reverted back to their original numbers when I open the embedded datasheet?

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)") #attribute 1
Steve Rindsberg - 25 Jul 2007 16:29 GMT
No clue how to do this with snakes, but with smoke and mirrors, aka vba, you need to call the Graph
application object's Update method before closing it.  Probably oGraph.Update will do it.

> Hey all,
>
[quoted text clipped - 21 lines]
>
> 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)
[quoted text clipped - 6 lines]
>      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
[quoted text clipped - 6 lines]
>     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" ))
[quoted text clipped - 3 lines]
> ## attribute(ROW NUMBER, BASE ROW NUMBER, SLIDE NUMBER)
> attributesbyID(14,12,839,"Attributes(116-144)") #attribute 1

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Lance Hoffmeyer - 26 Jul 2007 02:44 GMT
That did the trick,

Thanks Steve

For anyone who may be interested here is the final incantation of this function.

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

> No clue how to do this with snakes, but with smoke and mirrors, aka vba, you need to call the Graph
> application object's Update method before closing it.  Probably oGraph.Update will do it.

> -----------------------------------------
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
Steve Rindsberg - 26 Jul 2007 14:26 GMT
> That did the trick,

Great ... and thanks for posting the results.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.