Refresh a graph while macro is running

sapka

Board Regular
Joined
Nov 9, 2009
Messages
110
Hello,
How can I do a refresh of a graph while macro is still running?
In my case all changes to the graph are applied only when macro is finished.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Use DoEvents in the code.
The graph will refresh each time DoEvents is called.
Also be sure that Application.ScreenUpdating = True
 
Last edited:
Upvote 0
Sadly it is not working like that. I forgot to say that I am using it for PowerPoint 2010, not Excel.

Code:
Sub test()
Dim objSlide As Slide
Dim objGraph As Object

Set objSlide = ActivePresentation.Slides(1)
Set objGraph = objSlide.Shapes(1)
    
    With objGraph.Chart    
    For i = 1 To .SeriesCollection(1).Points.Count
        .SeriesCollection(1).Points(i).Format.Line.Visible = msoFalse
        .Refresh
        DoEvents
        Sleep 200
    Next i
    End With

End Sub
 
Upvote 0
Have not PowerPoint 2010.
Not sure but after playing with PP 2003 model, it seems the common workaround can be in activating/auto-deactivating of dummy userform.
Create small empty UserForm1 and put this code into it:
Rich (BB code):

' Code of the dummy(empty) UserForm1
Private Sub UserForm_Activate()
  ' Unload form immediately to provide refreshing of the active slide
  Unload Me
End Sub

In For-Next code of chart animation use UserForm1.Show to provide slide refreshing.
That is, replace in your code .Refresh by UserForm1.Show

Hope this will help
 
Last edited:
Upvote 0
Still not working. All I see is how UserForm loads and unloads (many times), and after this process is done, combined graph changes are applied.
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top