ppt embedded object numbers reverting back to original numbers

L

Lance Hoffmeyer

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
 
S

Steve Rindsberg

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,

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" ))
 
L

Lance Hoffmeyer

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
 

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

Similar Threads

vba msgraph changing font 3

Top