How to fix Automation error Object is not connected to server
I have an MS Access database with a table that has an OLE Object type field.
The field stores a PowerPoint slide associated with the rest of the data in the record.
I have a form with a bound object frame for the OLE Object field.
There is a Button on the form with VBA code that updates the graphics on the slide based on other information in the database.
For almost a decade, this has worked without any problems.
Within the last few weeks, it no longer works as before.
The subroutine works once, on any record. It errors when it runs on any subsequent record.
The Object in the bound object frame displays correctly in the Watch Window the first time the subroutine runs.
It does not display anything in the watch window when it is run again.
Nothing has changed in the subroutine. As I said: it has been running fine for years.
The content of the records does not make a difference. I have run archived versions from a few months ago, and the same error now presents itself.
What has changed in the last update to affect OLE automation in this way?
I am running Version 2408 (Build 17928.20216 Click-to-Run)
Here is a sample of code that duplicates the problem
Private Sub cmdUpdateSlide_Click()
Dim pptSlide As PowerPoint.Slide
Dim shpTemp As Shape
'seed the random number function
Rnd (Now())
'Error occurs here on subsequent runs
Set pptSlide = Me.frmSlide.Object
'adds a random dark red rectangle to the slide's shapes colection
Set shpTemp = pptSlide.Shapes.AddShape(msoShapeRectangle, Rnd() * 72, Rnd() * 72, Rnd() * 144, Rnd() * 144)
shpTemp.Fill.ForeColor.RGB = RGB(128, 0, 0)
'trigger the record update by changing focus from the button that triggered this subroutine
Me.frmSlide.SetFocus
End Sub
Error Message below: