How to use in Office Word Addin?
Hi, I am a beginner of Ole, how can I use this OleServer in Office Word?
This is how I currently do it.
var oleShape = doc.InlineShapes.AddOLEObject("SharpOleTest.COLEObjectTest", Type.Missing, false, false, Type.Missing, Type.Missing, Type.Missing).OLEFormat;
我想实现当我在Word中双击指定的Ole对象图片时出现我的OleServer
感谢留言。
这个项目并不是打算提供开包即用的OLE功能,它只是一个很简单的小例子,用来实现复制可以在Word里渲染的OLE对象的功能,所以应该是做不到双击编辑操作的。
想要双击编辑应该要重写Main函数然后在操作系统里注册COM对象ID和你的程序,具体的方法我现在不太记得了,如果你有需要我可以周末确认一下。你有兴趣的话也可以去研究一下VC++里的MFC框架,OLE功能实现最完善的就是MFC框架了。
Thanks Reply. At present, I want to implement this function, but my knowledge in this area is not enough. If you have free time on the weekend, please guide me, thank you very much!
------------------ 原始邮件 ------------------ 发件人: "Zhenwei @.>; 发送时间: 2022年8月11日(星期四) 晚上10:04 收件人: @.>; 抄送: "🔰BL. @.>; @.>; 主题: Re: [acaly/SharpOle] How to use in Office Word Addin? (Issue #1)
感谢留言。
这个项目并不是打算提供开包即用的OLE功能,它只是一个很简单的小例子,用来实现复制可以在Word里渲染的OLE对象的功能,所以应该是做不到双击编辑操作的。
想要双击编辑应该要重写Main函数然后在操作系统里注册COM对象ID和你的程序,具体的方法我现在不太记得了,如果你有需要我可以周末确认一下。你有兴趣的话也可以去研究一下VC++里的MFC框架,OLE功能实现最完善的就是MFC框架了。
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
I found an old book INSIDE OLE 2, published by Microsoft in 1994. I think I can try to write a working example, but it will take me some time, probably a few weeks.
If you want it very soon, this is the steps towards an editable OLE object:
- Ensure COM library can find the executable, which can be either a DLL or an EXE, by adding to the system registry. For DLL, we need to export a function called
DllGetClassObjectto create COM objects of specific CLSID. For EXE, we need to callCoRegisterClassObjectAPI providing our ownIClassFactoryobject when launched with the-Embeddingcommand line parameter. I am not sure how .NET of today can help us with these steps. Maybe we only need to apply attributes like I did in this project. Need some test. - There are 2 methods of editing. The simpler one is to edit in our own process. The user will see our application being started once double clicked over the embedded object. For this to work, in the implementation of
IOleObject, we need to provide editing verbs, and when the editing is triggered, show our window in a special mode (e.g., without Save/Save As menus) and start editing the OLE object. Interacting with the host application should be through theIAdviseSinkinterface received from the OLE object. - The harder way is to embed an editor inside the host application. For this to work, the implementation must be in a DLL. This is done with a new interface
IOleInPlaceActiveObjecton the OLE object. When the host wants an in-place editing, this interface will receive anIOleInPlaceSitethrough a call, which is then used to interact with the UI of the host application. I would say this mode worked well with old UI styles on Windows that uses standard menus and toolbars, but might be problematic on today's application full of custom UI elements and ribbons.
There are many details that I need to confirm. Making a full-featured OLE application is quite hard. I think I may end up with an example that is capable with out-of-process editing and nothing more. If you want to try yourself and have any questions, feel free to comment here.
Thanks Kopp, these solutions look cool, but I've never worked with MFC (it took me a lot of time to compile my FirstMFCApp). As you said "I like C#", I want to implement this functionality on .Net.
Of course, if .Net really doesn't work, I think I can spend time researching how to combine them.
Take the liberty to ask, are you from China?
.NET can do almost everything that C++ does. Also COM interop is one of the features of .NET since its first version. So what I talked about are all for C#. Don't worry.
I stayed in Canada for some years and have come back to China recently.
噢 Nice, 我好像可以省略谷歌翻译这一步了。您有空的话,能给我弄个demo吗?
可以弄个demo,但是不一定很快完成。
可以大概问一下你打算拿来做什么吗?是个人项目吗?
嗯 我想做一个Office Word的一个工具箱,卡在这里几天了
我看了一下 Inside Ole 2后,结合您的这个SharpOle,于是想自己用C#实现一下,能方便加一下您的QQ或者微信吗?
我的QQ:1259935112