성낙기
성낙기

Reputation: 1

How to update multiple origin OLEs embedeed in Power Point?(Python,OriginPro)

I really need your help. I would greatly appreciate any advice you can give.

I am trying to sequentially open multiple OriginPro OLE objects embedded in a PowerPoint slide and automatically update the worksheets originally inside each object, but I am facing an issue.

When multiple OLE objects are open, op.find_sheet(origin function) only calls the first opened OLE object, so I cannot update the next one. so I tried using op.exit or doverb(0) to close the first OLE object and then reconnect the application with op.attach(origin function) to update the next OLE object, but I am unable to establish the reconnection to the origin application.

The approximate code is as follows:

import os
import win32com.client
import originpro as op

powerpoint =             win32com.client.Dispatch("PowerPoint.Application")
powerpoint.Visible = True

origin = win32com.client.Dispatch("Origin.ApplicationSI")

origin.Visible = True

 for slide_index, slide in enumerate(presentation.Slides)

 for shape_index, shape in   enumerate(slide.Shapes):

ole_name = shape.Name

if "origin" in ole_name.lower():

shape.OLEFormat.DoVerb(1)

wks = op.find_sheet('w', 0)
wks.from_df(data)
shape.OLEFormat.DoVerb(0)
op.detatch()
op.utils.exit()
op.attach()

I can successfully iterate through and open OLE objects, but after closing the completed OLE object, an error occurs when trying to reconnect with Origin.

additionally, I tried using time.sleep and gc.collect, but it didn’t work well.

Upvotes: 0

Views: 32

Answers (0)

Related Questions