PDA

View Full Version : Embedded Excel object in PowerPoint not keeping VBA data updates.



mooseman
01-09-2017, 08:47 AM
For Office 2016 on Windows7
I have this code that updates the data in a standard embedded excel object (not a chart) and when the code runs the object shows the change, but if I save the file then open it and double click the object to activate it, the data all disappears. If I run some code to activate (double click) then the data is "saved"
Does anyone else have this problem or know what is wrong?
Is there something else I need to do to the with code block that updates the embedded object?


Sub Slide_16(xlWorkBook, company, lDate) ' I bring in the workbook object and two text variables
For Each oSH In ActivePresentation.Slides(16).Shapes
Select Case oSH.Name 'find the objects by the name I have given them
Case "Top_Item_16"
lrow = xlWorkBook.Worksheets(21).Range("B1").CurrentRegion.Rows.Count 'just finds last row of data

oSH.Chart.ChartTitle.Text = company & Chr(10) & "STop products" & Chr(10) & "26 Weeks Ending " & lDate

With oSH.Chart.ChartData
'this updates the values in the datasheet

.Workbook.sheets(1).Range("E1:H" & lrow).Value = xlWorkBook.sheets(21).Range("A1:D" & lrow).Value

End With



Case "Footer"
message = "Source:database- " & company & " " & lDate & " Confidential"
oSH.TextFrame.WordWrap = msoFalse
oSH.TextFrame.AutoSize = ppAutoSizeShapeToFitText
oSH.TextFrame.TextRange.Text = message
End Select

Next oSH


End Sub

mooseman
01-10-2017, 09:12 AM
I posted the wrong code and can't find the edit for my post so here is the correct code.


Sub Slide_18(xlWorkBook, company, lDate)


For Each oSH In ActivePresentation.Slides(18).Shapes
Select Case oSH.Name
Case "Key_SKU_18"
lrow = xlWorkBook.Worksheets(23).Range("B1").CurrentRegion.Rows.Count
oSH.OLEFormat.Object.sheets(1).Range("A2:L" & lrow).Value = xlWorkBook.sheets(23).Range("A2:L" & lrow).Value

Case "Title Object"
oSH.TextFrame.TextRange.Text = company & Chr(10) & "Benchmark " & Chr(10) & "13 Weeks Ending " & lDate



Case "Footer"
message = company & " as of - " & lDate & " Confidential" 'need the date from the data file
oSH.TextFrame.WordWrap = msoFalse
oSH.TextFrame.AutoSize = ppAutoSizeShapeToFitText
oSH.TextFrame.TextRange.Text = message
End Select


Next oSH

End Sub