Page 1 of 1
[Solved] Macro to insert an OLE object
Posted: Fri Jan 16, 2009 11:20 pm
by fmolina
Hi all:
This may be a silly question, but I could not find the answer, so please forgive me. I am using OOo 3.0 on windows XP SP3.
I want to write a macro to insert a new OLE object into a Writer document and start the server. More specifically, I want to insert a new MathType equation, thus openieng the OLE server. How to do that? I tried to record a macro but it only opens the dialog.
Thank you in advance.
Fer
Re: Macro to insert an OLE object
Posted: Sat Jan 17, 2009 12:20 am
by Villeroy
Re: Macro to insert an OLE object
Posted: Sat Jan 17, 2009 5:18 pm
by fmolina
Thanks Villeroy, I found code but , seems to not be working in 3.0.
Specifically, I found this:
http://www.oooforum.org/forum/viewtopic ... hlight=ole
(first example) but it does not work well: It opens OOo Math but then starts an endless chain of beeps and does not respond anymore. I must kill OOo Writer to stop.
¿Someone has any further advice?
Regards
Re: Macro to insert an OLE object
Posted: Mon Jan 19, 2009 5:04 am
by ms777
Ooops - I will check that in two weeks when I am back at my computer. I am still at OO 2.4
To insert OO objects into writer, I would recommend an easier way:
1.) create an ole2shape by the document's createInstance method
2.) insert it into drawpage
3.) set the CLSID to the math formula CLSID. You can get that by xraying a doc with an formula inserted
see
http://www.oooforum.org/forum/viewtopic.phtml?t=61104 as a java example
For then activating / modifying the inserted formula see
http://www.oooforum.org/forum/viewtopic.phtml?t=78793
Good luck,
ms777
Re: Macro to insert an OLE object
Posted: Tue Jan 20, 2009 3:50 pm
by fmolina
Thanks, ms777, I will chek that and tell what happened
Regards
Re: Macro to insert an OLE object
Posted: Tue Jan 20, 2009 9:04 pm
by fmolina
OK, it worked, borrowing some code from Andrew Pitonyak's macro guide. The code to insert a MathType 6 equation is
Code: Select all
sub InsertMathTypeEcuation
rem ----------------------------------------------------------------------
rem define variables
dim obj as object
dim SName as string
dim oXEO as object
rem ----------------------------------------------------------------------
SName = "com.sun.star.text.TextEmbeddedObject"
obj = ThisComponent.createInstance(sName)
obj.CLSID = "0002CE03-0000-0000-C000-000000000046"
obj.attach(ThisComponent.currentController().Selection.getByIndex(0))
oXEO = obj.ExtendedControlOverEmbeddedObject
oXEO.doVerb(0)
end sub
By the way, I tried a bit to do the same with OOo Math but without success. Not a big deal, because there is a button to do that.
Regards,
Fernando
Re: [Solved] Macro to insert an OLE object
Posted: Mon Apr 03, 2017 1:21 pm
by SanchoPanza
Given links are not working. I want to insert a ole object from a specified path by using macro. I tried to record a macro to reach dispatchers but it didn't help me. Also I couldn't find any solution to my problem. Is there any way to do it? Thanks.