[Solved] Macro to insert an OLE object

Keyboard macros or custom scripts

[Solved] Macro to insert an OLE object

Postby fmolina » Fri Jan 16, 2009 11:20 pm

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
Last edited by fmolina on Tue Jan 20, 2009 9:05 pm, edited 1 time in total.
OOo 3.0.X on Ms Windows XP + fedora linux/solaris (to be)
fmolina
 
Posts: 4
Joined: Fri Jan 16, 2009 10:15 pm

Re: Macro to insert an OLE object

Postby Villeroy » Sat Jan 17, 2009 12:20 am

Search the ol' forum's "Code Snippets" forum for "OLE". http://www.oooforum.org/forum/search.phtml
One of the results: http://www.oooforum.org/forum/viewtopic ... hlight=ole
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25436
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macro to insert an OLE object

Postby fmolina » Sat Jan 17, 2009 5:18 pm

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
OOo 3.0.X on Ms Windows XP + fedora linux/solaris (to be)
fmolina
 
Posts: 4
Joined: Fri Jan 16, 2009 10:15 pm

Re: Macro to insert an OLE object

Postby ms777 » Mon Jan 19, 2009 5:04 am

fmolina wrote:...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....


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
ms777
Volunteer
 
Posts: 130
Joined: Mon Oct 08, 2007 1:33 am

Re: Macro to insert an OLE object

Postby fmolina » Tue Jan 20, 2009 3:50 pm

Thanks, ms777, I will chek that and tell what happened

Regards
OOo 3.0.X on Ms Windows XP + fedora linux/solaris (to be)
fmolina
 
Posts: 4
Joined: Fri Jan 16, 2009 10:15 pm

Re: Macro to insert an OLE object

Postby fmolina » Tue Jan 20, 2009 9:04 pm

OK, it worked, borrowing some code from Andrew Pitonyak's macro guide. The code to insert a MathType 6 equation is
Code: Select all   Expand viewCollapse view
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
OOo 3.0.X on Ms Windows XP + fedora linux/solaris (to be)
fmolina
 
Posts: 4
Joined: Fri Jan 16, 2009 10:15 pm

Re: [Solved] Macro to insert an OLE object

Postby SanchoPanza » Mon Apr 03, 2017 1:21 pm

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.
OpenOffice 4.1.3 on Windows 10
SanchoPanza
 
Posts: 5
Joined: Tue Mar 21, 2017 7:46 am


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 4 guests