The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Python
 Updating Origin OLE in a PowerPoint File(pywin32)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

nk.S

Republic of Korea
6 Posts

Posted - 11/17/2024 :  4:03:55 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): origin2023
Operating System: windows, pycharm


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

I am trying to sequentially open multiple Origin 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 only calls the first opened OLE object, so I cannot update the next one. I tried using op.utils.exit to close the first OLE object and then reconnect the application with op.attach() to update the next OLE object, but I am unable to establish the connection to the 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()

presentation.Save()
presentation.Close()
powerpoint.Quit()
op.exit()


sng

nk.S

Republic of Korea
6 Posts

Posted - 11/29/2024 :  07:50:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I’ve been unable to resolve the problem with reconnecting the Origin application, so I’m exploring other methods.

Here’s my next question: I’m trying to access the OLE object and edit the worksheet using COM instead of op.find_sheet. Accessing the worksheet and clearing the content works, but I’m not sure how to insert data correctly. Could you provide some advice?

code is as below.

-----------------------------
shape.OLEFormat.DoVerb(1)

for i in range(layer_count):
layer = page.Layers(i)

if layer.TypeName == "Worksheet":

layer.DoMethod('Clear', '') # good works
op.lt_exec("win -pa") # window activte
data.to_clipboard(index=False)
op.lt_exec(f"win -a {layer.Name}") # it's not working

presentation.Save()
presentation.Close()
powerpoint.Quit()
op.exit()




sng

Edited by - nk.S on 11/29/2024 07:55:12 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000