View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
skif skif is offline
external usenet poster
 
Posts: 2
Default Graph object always missed info.

The question is:

i have Excel file updated on daily basis. I need to refresh PowerPoint
presentation file after this because ppt Graph should be also updated.

Here is a peace of code:

SayStatusBar "Loading data from Excel file..."

Set objXlsApp = CreateObject("Excel.Application")
objXlsApp.Visible = True
objXlsApp.DisplayAlerts = False
objXlsApp.Interactive = False
objXlsApp.AskToUpdateLinks = False
objXlsApp.Workbooks.Open TxtXlsSrcFile.Text, ReadOnly:=True
Set objSrcWorkbook =
objXlsApp.Workbooks(GetShortFileName(TxtXlsSrcFile .Text))

SayStatusBar "Creating presentation object..."
' create presentation object
Set objPpt = CreateObject("PowerPoint.Application")
objPpt.Activate

' open old file as template
objPpt.Presentations.Open TxtPptSrcFile.Text ', msoTrue

' save under new name
objPresentation.SaveAs TxtPptDestFile.Text

lngSlideCount = objPresentation.Slides.Count
For i = 1 To lngSlideCount

' here is a source worksheet
Set objSrcSheet = objSrcWorkbook.Worksheets('Sheet1$')
' Graph object
Set objChart = objSlide.Shapes.Item(1).objShape.OLEFormat.Object

With objChart.Application.DataSheet

' copy rows
For i = 0 To (lngXlsRowEnd - lngXlsRowStart)

' copy cols
For j = 0 To (lngXlsColEnd - lngXlsColStart)

.Cells(lngGraphRowStart + i, lngGraphColStart + j).Value
= _
objSrcSheet.Cells(lngXlsRowStart + i, lngXlsColStart
+ j).Value

Next j

Next i

End With

objChart.Refresh

next i

Label1:
objChart.Refresh

SayStatusBar "Saving results..."
objPresentation.Save
set objPresentation = nothing.....
objPpt.Quit
Set objPpt = nothing
...

The problem is: without calling objChart.Refresh i always saw the info
like in old file - no changes (but in debugger i see the differences!).
With using objChart.Refresh i can save file with a new info. But when i
opened a new file after save and "double click" on Chart - new info
disappears and Graph looks like old one (1 second ago it looks like
new!). TBC: If i will make a pause at Label1 (messagebos, for example),
switch to PPT application, make some clicks (no changes) and after that
resume my application - all info saved in the new file and never revert
back.

So where is my mistake and how to correctly update a Chart in PowerPoint
presentation?

Thanks in advance.
Igor



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!