问题
I'm new to this and basically what I want to do is:
-I have 2 excel files and 1 powerpoint presentation -all of the files are in a shared network -I linked my excel files to the powerpoint -I have office 2003 and 2007 versions
The problem:
I play the slideshow of the powerpoint and set it to loop on 1 computer to display it on a big LCD at work, I then access the excel files on a separate computer and update it from there, the problem is the slideshow that is playing wont display my changes automatically. I have to manually stop the show and click the (update link) on the slides to have it show the updates I just inputted.
Is there a way so that the slideshow will display my updated data within the show and I wont have to manually stop it and click the update link.
I have found a somewhat similar question here but it was not answered to the point where it will help me advance my question.
回答1:
I've solve the problem above using this code
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = 2 Then
ActivePresentation.UpdateLinks
End If
End Sub
Assuming I have 2 slides in the show, when is passes on slide 2 it will trigger the update links and loops back to slide 1 with the updated OLE links. It took me a lot of reading to get to this part but I cant get it to run when I start the show. I have to manually press alt+F8 and click run so the code will loop every slide 2.
EDIT: Finally got it working without running the macro once. i just open the powerpoint and play the show. the updates were dynamically updated when the show passed slide 2 or just the beginning. Now there are some that still dont have solutions for this problem, hope this helps you.
I utilized the autoevent.zip found here at http://skp.mvps.org/autoevents.htm. I installed the AutoEvents.ppa included in the zip as an Add In and activated it in PPT2007 and PPT2003. and then created a normal module/macro with this code.
Sub Auto_ShowBegin()
ActivePresentation.UpdateLinks
End Sub
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
'
' AUTO UPDATE OF OLE LINKS MACRO
'
If SSW.View.CurrentShowPosition = 2 Then
ActivePresentation.UpdateLinks
End If
End Sub
And your done. Please make sure that you save your powerpoint in macro-enabled format both for 2003 and 2007, this is because I have two versions of ms office. and tick the ckeck box saying -Trust access to the VBA project object model. Also loop your slideshow so that when it passed the slide 2 or just the beginning of the show, it will update all OLE links.
Do comment if I have missed something. Hope this helps.
回答2:
I think you need code for this.
Add a new class module to your presentation and name it "clsEvents". Add this code:
Public WithEvents PPTEvent As Application
Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Dim objSld As Slide, shp As Shape
Set objSld = Wn.Presentation.Slides(Wn.View.CurrentShowPosition)
For Each shp In objSld.Shapes
If shp.Type = msoLinkedOLEObject Then
shp.LinkFormat.Update
End If
Next shp
End Sub
In a normal module put:
Dim app As clsEvents
Sub SetUpEvents()
Set app = New clsEvents
Set app.PPTEvent = Application
End Sub
Run setupevents before starting the slideshow.
来源:https://stackoverflow.com/questions/11662108/linked-excel-object-in-powerpoint-wont-update-when-showing-in-slideshow